BUTR/Bannerlord.BLSE

View on GitHub

Showing 240 of 240 total issues

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

internal sealed class UILauncherPrefabExtension6 : PrefabExtensionInsertAsSiblingPatch
{
    public static string Movie => "UILauncher";
    public static string XPath => "descendant::TabToggleWidget[2]";

src/Bannerlord.LauncherEx/PrefabExtensions/UILauncherPrefabExtension.Mods.Saves.cs on lines 8..28

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 201.

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

internal sealed class UILauncherPrefabExtension24 : PrefabExtensionInsertAsSiblingPatch
{
    public static string Movie => "UILauncher";
    public static string XPath => "descendant::TabToggleWidget[5]";

src/Bannerlord.LauncherEx/PrefabExtensions/UILauncherPrefabExtension.Options.cs on lines 68..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 201.

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

internal sealed class UILauncherPrefabExtension21 : PrefabExtensionInsertAsSiblingPatch
{
    public static string Movie => "UILauncher";
    public static string XPath => "descendant::TabToggleWidget[4]";

src/Bannerlord.LauncherEx/PrefabExtensions/UILauncherPrefabExtension.Options.cs on lines 89..109

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 195.

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

internal sealed class UILauncherPrefabExtension20 : PrefabExtensionInsertAsSiblingPatch
{
    public static string Movie => "UILauncher";
    public static string XPath => "descendant::TabToggleWidget[3]";

src/Bannerlord.LauncherEx/PrefabExtensions/UILauncherPrefabExtension.Options.cs on lines 110..130

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 195.

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 Enable has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static void Enable()
    {
        ProgramPatch.Enable(_launcherHarmony);
        UserDataManagerPatch.Enable(_launcherHarmony);
        LauncherVMPatch.Enable(_launcherHarmony);
Severity: Major
Found in src/Bannerlord.LauncherEx/Manager.cs - About 2 hrs to fix

    Method ShowDialog has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public override bool ShowDialog()
        {
            FileNames = null;
    
            var file = Marshal.AllocHGlobal(MAX_FILE_LENGTH * Marshal.SystemDefaultCharSize);
    Severity: Major
    Found in src/Bannerlord.LauncherEx/Helpers/Input/OpenSaveDialogs.cs - About 2 hrs to fix

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

              SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
              {
                  DisplayName = new BUTRTextObject("{=5XzSM7RN}Restore Engine Options Backup").ToString(),
                  HintText = new BUTRTextObject("{=uKUsA3Sp}LauncherEx always makes a backup before saving the first time. This will restore the original files").ToString(),
                  SettingType = SettingType.Button,
      src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 133..148

      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 177.

      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

              SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
              {
                  DisplayName = new BUTRTextObject("{=IsR2rbnG}Restore Game Options Backup").ToString(),
                  HintText = new BUTRTextObject("{=uKUsA3Sp}LauncherEx always makes a backup before saving the first time. This will restore the original files").ToString(),
                  SettingType = SettingType.Button,
      src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 149..164

      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 177.

      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 ValidateSave has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void ValidateSave()
          {
              var changeset = _saveMetadata.GetChangeSet();
              var modules = _saveMetadata.GetModules().Select(x =>
              {
      Severity: Major
      Found in src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherSaveVM.cs - About 2 hrs to fix

        Method SplitCommandLine has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
        Open

            public static IEnumerable<string> SplitCommandLine(string commandLine)
            {
                var startTokenIndex = 0;
        
                var pos = 0;
        Severity: Minor
        Found in src/Bannerlord.BLSE/Utils/CommandLineSplitter.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 SaveLauncherOptions has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void SaveLauncherOptions()
            {
                if (_launcherExData is null)
                    return;
        
        
        Severity: Major
        Found in src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs - About 2 hrs to fix

          Method ReadLine16bpp has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  private void ReadLine16bpp(SimpleBinaryStream input, PipelineWriter output, ushort[] buffer)
                  {
                      var normalized = true;
                      switch (format)
                      {
          Severity: Major
          Found in src/Bannerlord.LauncherEx/TPac/TextureUtils.cs - About 2 hrs to fix

            Class StringHelper has 22 methods (exceeds 20 allowed). Consider refactoring.
            Open

            file static class StringHelper
            {
                /// <summary>Allocates a block of memory allocated from the unmanaged COM task allocator sufficient to hold the number of specified characters.</summary>
                /// <param name="count">The number of characters, inclusive of the null terminator.</param>
                /// <param name="memAllocator">The method used to allocate the memory.</param>
            Severity: Minor
            Found in src/Bannerlord.LauncherEx/Helpers/Input/OpenSaveDialogs.cs - About 2 hrs to fix

              Method Load has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected virtual void Load(BinaryReader stream)
                  {
                      if (!stream.BaseStream.CanSeek)
                          throw new IOException("The base stream must support random access (seek).");
                      HeaderLoaded = true;
              Severity: Major
              Found in src/Bannerlord.LauncherEx/TPac/AssetPackage.cs - About 2 hrs to fix

                Identical blocks of code found in 4 locations. Consider refactoring.
                Open

                If the module was installed manually, try to do a clean reinstall!
                If Vortex is used, try to reinstall manually!
                If Steam is used, download the Harmony mod from NexusMods!
                Don't forget that on Steam you have the '/Modules' folder in the Game
                and the Steam Workshop folder that can conflict with each other!
                Severity: Major
                Found in src/Bannerlord.BLSE.Shared/ModuleInitializer.cs and 3 other locations - About 2 hrs to fix
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 53..61
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 66..74
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 105..113

                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 164.

                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

                Identical blocks of code found in 4 locations. Consider refactoring.
                Open

                If the module was installed manually, try to do a clean reinstall!
                If Vortex is used, try to reinstall manually!
                If Steam is used, download the Harmony mod from NexusMods!
                Don't forget that on Steam you have the '/Modules' folder in the Game
                and the Steam Workshop folder that can conflict with each other!
                Severity: Major
                Found in src/Bannerlord.BLSE.Shared/ModuleInitializer.cs and 3 other locations - About 2 hrs to fix
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 53..61
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 66..74
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 92..100

                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 164.

                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

                Identical blocks of code found in 4 locations. Consider refactoring.
                Open

                If the module was installed manually, try to do a clean reinstall!
                If Vortex is used, try to reinstall manually!
                If Steam is used, download the Harmony mod from NexusMods!
                Don't forget that on Steam you have the '/Modules' folder in the Game
                and the Steam Workshop folder that can conflict with each other!
                Severity: Major
                Found in src/Bannerlord.BLSE.Shared/ModuleInitializer.cs and 3 other locations - About 2 hrs to fix
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 66..74
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 92..100
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 105..113

                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 164.

                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

                Identical blocks of code found in 4 locations. Consider refactoring.
                Open

                If the module was installed manually, try to do a clean reinstall!
                If Vortex is used, try to reinstall manually!
                If Steam is used, download the Harmony mod from NexusMods!
                Don't forget that on Steam you have the '/Modules' folder in the Game
                and the Steam Workshop folder that can conflict with each other!
                Severity: Major
                Found in src/Bannerlord.BLSE.Shared/ModuleInitializer.cs and 3 other locations - About 2 hrs to fix
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 53..61
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 92..100
                src/Bannerlord.BLSE.Shared/ModuleInitializer.cs on lines 105..113

                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 164.

                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 Enable has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static bool Enable(Harmony harmony)
                    {
                        PrefabExtensionManager.RegisterPatch(UILauncherPrefabExtension31.Movie, UILauncherPrefabExtension31.XPath, new UILauncherPrefabExtension31());
                        PrefabExtensionManager.RegisterPatch(UILauncherPrefabExtension32.Movie, UILauncherPrefabExtension32.XPath, new UILauncherPrefabExtension32());
                        PrefabExtensionManager.RegisterPatch(UILauncherPrefabExtension34.Movie, UILauncherPrefabExtension34.XPath, new UILauncherPrefabExtension34());
                Severity: Major
                Found in src/Bannerlord.LauncherEx/Patches/WidgetPrefabPatch.cs - About 2 hrs to fix

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

                      internal static bool Enable(Harmony harmony)
                      {
                          _harmony = harmony;
                  
                          var res1 = harmony.TryPatch(
                  src/Bannerlord.BLSE/Features/Interceptor/Patches/ModulePatch.cs on lines 18..33

                  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 161.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language