< Summary

Class:DCL.UIComponents.CodeStyleExample
Assembly:Assembly-CSharp
File(s):/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/CodeStyleExample.cs
Covered lines:0
Uncovered lines:29
Coverable lines:29
Total lines:131
Line coverage:0% (0 of 29)
Covered branches:0
Total branches:0

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
CodeStyleExample()0%2100%
CodeStyleExample()0%2100%
Initialize()0%2100%
ApplyDamage(...)0%2100%
ComputeDamage(...)0%2100%
TakeHit(...)0%2100%
Hide()0%2100%
SetVisibility(...)0%2100%
Awake()0%2100%
Start()0%6200%
OnEnable()0%2100%
OnClosed(...)0%2100%
OnDisable()0%2100%
OnDestroy()0%6200%
Method1()0%2100%
Method2()0%2100%
Method3()0%2100%

File(s)

/tmp/workspace/unity-renderer/unity-renderer/Assets/Scripts/CodeStyleExample.cs

#LineLine coverage
 1// NOTE: following separation lines (//----- some group) are used only for clarity and do not take part of our commentin
 2
 3//----------------------------------------------------------------------------------------------------  Usings group
 4using EasyButtons;
 5using JetBrains.Annotations;
 6using System;
 7using System.Collections.Generic;
 8using UnityEngine;
 9using UnityEngine.Events;
 10
 11namespace DCL.UIComponents
 12{
 13    //------------------------------------------------------------------------------------------------  Enum, delegates,
 14    public enum Side { Left, Right }
 15
 16    public delegate void Destroction<T> (T current);
 17
 18    public interface IInitializable
 19    {
 20        bool IsInitialized { get; }
 21
 22        void Initialize();
 23    }
 24
 25    [RequireComponent(typeof(Animation))]
 26    public class CodeStyleExample : MonoBehaviour, IInitializable
 27    {
 28        //----------------------------------------------------------------------------------------  Enum, delegates decl
 29        private enum Direction { North, South, West, East }
 30        private delegate void Interaction<T> (T current);
 31
 32        //----------------------------------------------------------------------------------------  Const and static rea
 33        public const string ASSET_PATH = "AvatarPrefab";
 34        private const float MAX_TIMER = 10f;
 35
 036        public static readonly int WAVE_ANIM_HASH = Animator.StringToHash("Wave");
 037        private static readonly int DANCE_ANIM_HASH = Animator.StringToHash("Dance");
 38
 39        //----------------------------------------------------------------------------------------  Events and UnityEven
 40        public event Destroction<CodeStyleExample> Destroyed;
 41        [NonSerialized] public UnityEvent<bool> Closed; // use [NonSerialized] or [HideInInspector] for UnityEvents
 42
 43        //----------------------------------------------------------------------------------------  Fields group (other 
 044        public readonly List<int> CachedNumbers = new List<int>();
 045        protected readonly List<Vector2> poistions = new List<Vector2>();
 46
 47        public int Timer;
 48
 49        [SerializeField] private AnimationClip[] clips;
 50        [SerializeField] private float armor;
 51        [SerializeField] private float health;
 52        [SerializeField] private bool isVisitble;
 53
 54        protected float cooldown;
 55
 56        private new Animation animation;
 57        private Interaction<int> interactionsBuffer;
 58
 59        //----------------------------------------------------------------------------------------  Properties group
 060        public bool IsInitialized { get; private set; }
 61
 62        [PublicAPI]
 063        public bool IsVisitble => isVisitble; // [PublicAPI] Public - used only from outside of Unity solution (by other
 64
 65        //----------------------------------------------------------------------------------------  Public methods group
 66        public void Initialize() =>
 067            IsInitialized = true;
 68
 69        public void ApplyDamage(float damage) // Public - called from outside of the class (by other class)
 70        {
 071            float resultDamage = ComputeDamage(damage);
 072            TakeHit(resultDamage);
 073        }
 74
 75        private float ComputeDamage(float damage) => // Called by ApplyDamage
 076            damage - armor;
 77
 78        private void TakeHit(float amount) => // Called by ApplyDamage
 079            health -= amount;
 80
 81        [UsedImplicitly]
 82        public void Hide() => // [UsedImplicitly] Public - called implicitly, for example, by Unity animation events or 
 083            SetVisibility(visible: true);
 84
 85        private void SetVisibility(bool visible) => // Called by Hide
 086            isVisitble = visible;
 87
 88        //----------------------------------------------------------------------------------------  Unity callbacks meth
 89        private void Awake() // is used for getting references
 90        {
 091            animation = GetComponent<Animation>();
 092        }
 93
 94        private void Start() // is used for initialization logic
 95        {
 096            foreach (AnimationClip clip in clips)
 097                animation.AddClip(clip, clip.name);
 098        }
 99
 100        private void OnEnable() // is used for events subscription
 101        {
 0102            Closed.AddListener(OnClosed);
 0103        }
 104
 105        private void OnClosed(bool _) => // use _, __, ___ for parameters name if required parameters are not used insid
 0106            cooldown = MAX_TIMER;
 107
 108        private void OnDisable() // is used for events unsubscription
 109        {
 0110            Closed.RemoveListener(OnClosed);
 0111        }
 112
 113        private void OnDestroy() // is used for any needed clean-up
 114        {
 0115            Destroyed?.Invoke(this);
 0116        }
 117
 118        //----------------------------------------------------------------------------------------  internal-protected-p
 119        // methods that weren't called inside methods above 👆
 0120        internal void Method1() { }
 0121        protected void Method2() { }
 0122        private void Method3() { }
 123
 124        //----------------------------------------------------------------------------------------  Nested classes/struc
 125        private struct Data
 126        {
 127            public int A;
 128            public bool B;
 129        }
 130    }
 131}