BUTR/Bannerlord.YellToInspire

View on GitHub

Showing 18 of 18 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        protected override void OnAgentControllerChanged(Agent agent, Agent.ControllerType oldController)
        {
            base.OnAgentControllerChanged(agent, oldController);

            if (agent.Controller == Agent.ControllerType.Player)
src/Bannerlord.YellToInspire/MissionBehaviors/InspireGameplayCooldownBehaviour.cs on lines 25..45

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 187.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        protected override void OnAgentControllerChanged(Agent agent, Agent.ControllerType oldController)
        {
            base.OnAgentControllerChanged(agent, oldController);

            if (agent.Controller == Agent.ControllerType.Player)
src/Bannerlord.YellToInspire/MissionBehaviors/InspireGameplayKillingBehaviour.cs on lines 35..55

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 187.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method AffectTroops has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
Open

        public static (TroopStatistics Statistics, List<WeakReference<Agent>> AffectedAgents) AffectTroops(Agent causingAgent, Settings settings)
        {
            var vec2Pos = causingAgent.Position.AsVec2;
            var team = causingAgent.Team;

Severity: Minor
Found in src/Bannerlord.YellToInspire/Utils/CommonUtils.cs - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method AffectTroops has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public static (TroopStatistics Statistics, List<WeakReference<Agent>> AffectedAgents) AffectTroops(Agent causingAgent, Settings settings)
        {
            var vec2Pos = causingAgent.Position.AsVec2;
            var team = causingAgent.Team;

Severity: Minor
Found in src/Bannerlord.YellToInspire/Utils/CommonUtils.cs - About 1 hr to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            public override void OnAgentBuild(Agent agent, Banner banner)
            {
                base.OnAgentBuild(agent, banner);
    
                if (agent.Character is not { IsHero: true}) return;
    src/Bannerlord.YellToInspire/MissionBehaviors/InspireGameplayKillingBehaviour.cs on lines 12..23

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 135.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    using MCM.Abstractions.Attributes;
    using MCM.Abstractions.Attributes.v2;
    
    namespace Bannerlord.YellToInspire
    {
    Severity: Major
    Found in src/Bannerlord.YellToInspire/Settings.Cooldown.cs and 1 other location - About 1 hr to fix
    src/Bannerlord.YellToInspire/Settings.Killing.cs on lines 1..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 135.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            public override void OnAgentBuild(Agent agent, Banner banner)
            {
                base.OnAgentBuild(agent, banner);
    
                if (agent.Character is not { IsHero: true}) return;
    src/Bannerlord.YellToInspire/MissionBehaviors/InspireGameplayCooldownBehaviour.cs on lines 12..23

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 135.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    using MCM.Abstractions.Attributes;
    using MCM.Abstractions.Attributes.v2;
    
    namespace Bannerlord.YellToInspire
    {
    Severity: Major
    Found in src/Bannerlord.YellToInspire/Settings.Killing.cs and 1 other location - About 1 hr to fix
    src/Bannerlord.YellToInspire/Settings.Cooldown.cs on lines 1..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 135.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Method ShowDetailedMessage has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public static void ShowDetailedMessage(TroopStatistics troopsStatistics, bool showDetailedMessageText)
            {
                if (showDetailedMessageText)
                {
                    InformationManager.DisplayMessage(new(Strings.AlliesInspired.SetTextVariable("INSPIRED", troopsStatistics.Inspired).ToString()));
    Severity: Minor
    Found in src/Bannerlord.YellToInspire/Utils/CommonUtils.cs - About 1 hr to fix

      Method DelayAndReact has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              protected virtual void DelayAndReact()
              {
                  if (Settings is not { } settings) return;
      
                  foreach (var weakReference in _affectedAgents.ToList())

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if (commonAiComponent.IsRetreating)
                        {
                            if (causingAgent.Character is not CharacterObject charObj || charObj.GetPerkValue(Perks.Instance.InspireResolve))
                            {
                                nearbyAllyAgent.SetMorale(commonAiComponent.RecoveryMorale);
        Severity: Minor
        Found in src/Bannerlord.YellToInspire/Utils/CommonUtils.cs and 1 other location - About 45 mins to fix
        src/Bannerlord.YellToInspire/Utils/CommonUtils.cs on lines 89..98

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                        if (commonAiComponent.IsPanicked)
                        {
                            if (causingAgent.Character is not CharacterObject charObj || charObj.GetPerkValue(Perks.Instance.InspireResolve))
                            {
                                nearbyAllyAgent.SetMorale(commonAiComponent.RecoveryMorale);
        Severity: Minor
        Found in src/Bannerlord.YellToInspire/Utils/CommonUtils.cs and 1 other location - About 45 mins to fix
        src/Bannerlord.YellToInspire/Utils/CommonUtils.cs on lines 79..88

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 77.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                public float AlliedMoraleGain(BasicCharacterObject? character)
                {
                    var raw = BaseAlliedMoraleGain + (((float?) character?.GetSkillValue(Skills.Leadership) ?? 0f) * AlliedMoraleGainIncreasePerLevel);
                    return MathF.Clamp(raw, 0f, 100f);
                }
        Severity: Minor
        Found in src/Bannerlord.YellToInspire/Settings.cs and 1 other location - About 45 mins to fix
        src/Bannerlord.YellToInspire/Settings.cs on lines 19..23

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 74.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                public float AbilityRadius(BasicCharacterObject? character)
                {
                    var raw = BaseAbilityRadius + (((float?) character?.GetSkillValue(Skills.Leadership) ?? 0f) * AbilityRadiusIncreasePerLevel);
                    return MathF.Clamp(raw, 1f, 100f);
                }
        Severity: Minor
        Found in src/Bannerlord.YellToInspire/Settings.cs and 1 other location - About 45 mins to fix
        src/Bannerlord.YellToInspire/Settings.cs on lines 34..38

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 74.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    if (!Agent.Mission.GetNearbyEnemyAgents(Agent.Position.AsVec2, 8f, Agent.Team, new MBList<Agent>()).Any() && settings.EnableCheerAnimation)
                    {
                        Cheer(Agent);
                    }
        src/Bannerlord.YellToInspire/MissionBehaviors/AgentComponents/InspireNearAgentsAgentComponent.cs on lines 91..94

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 67.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                            if (!Agent.Mission.GetNearbyEnemyAgents(agent.Position.AsVec2, 8f, agent.Team, new MBList<Agent>()).Any() && settings.EnableCheerAnimation)
                            {
                                Cheer(agent);
                            }
        src/Bannerlord.YellToInspire/MissionBehaviors/AgentComponents/InspireNearAgentsAgentComponent.cs on lines 40..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 67.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Avoid too many return statements within this method.
        Open

                    if (!state.CanInspire()) return;

          Avoid too many return statements within this method.
          Open

                      if (!state.CanInspire(out _)) return;
            Severity
            Category
            Status
            Source
            Language