BUTR/Bannerlord.BLSE

View on GitHub

Showing 240 of 240 total issues

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

        SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
        {
            DisplayName = new BUTRTextObject("{=iD27wEq7}Hide Random Image").ToString(),
            HintText = new BUTRTextObject("{=LaPvZjwC}Hide's the Rider image so the launcher looks more compact").ToString(),
            SettingType = SettingType.Bool,
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 84..90
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 112..118
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 119..125
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 173..179
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 180..186
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 187..193

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

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 7 locations. Consider refactoring.
Open

        SettingProperties.Add(new SettingsPropertyVM(new SettingsPropertyDefinition
        {
            DisplayName = new BUTRTextObject("{=QJSBiZdJ}Beta Sorting").ToString(),
            HintText = new BUTRTextObject("{=HVhaqeb4}Uses the new sorting algorithm after v1.12.x. Disable to use the old algorithm").ToString(),
            SettingType = SettingType.Bool,
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 84..90
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 105..111
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 119..125
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 173..179
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 180..186
src/Bannerlord.LauncherEx/ViewModels/BUTRLauncherOptionsVM.cs on lines 187..193

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

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

    private void SetState()
    {
        if (ViewModel is null) return;

        OnPropertyChanged(nameof(IsSingleplayer2));
Severity: Minor
Found in src/Bannerlord.LauncherEx/Mixins/LauncherVMMixin.cs - About 1 hr to fix

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

                    case TextureFormat.R16G16_UNORM:
                        for (int i = 0, j = 0; i < width; i++, j = i * 4)
                        {
                            buffer[j] = input.ReadUInt16();
                            buffer[j + 1] = input.ReadUInt16();
    Severity: Major
    Found in src/Bannerlord.LauncherEx/TPac/TextureUtils.cs and 3 other locations - About 1 hr to fix
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 366..374
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 523..531
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 552..560

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

    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 4 locations. Consider refactoring.
    Open

                    case TextureFormat.R24G8_TYPELESS:
                        for (int i = 0, j = 0; i < width; i++, j = i * 4)
                        {
                            buffer[j] = input.ReadUInt24();
                            buffer[j + 1] = input.ReadByte();
    Severity: Major
    Found in src/Bannerlord.LauncherEx/TPac/TextureUtils.cs and 3 other locations - About 1 hr to fix
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 366..374
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 466..474
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 523..531

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

    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 4 locations. Consider refactoring.
    Open

                    case TextureFormat.R8G8_UNORM:
                        for (int i = 0, j = 0; i < width; i++, j = i * 4)
                        {
                            buffer[j] = input.ReadByte();
                            buffer[j + 1] = input.ReadByte();
    Severity: Major
    Found in src/Bannerlord.LauncherEx/TPac/TextureUtils.cs and 3 other locations - About 1 hr to fix
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 466..474
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 523..531
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 552..560

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

    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 4 locations. Consider refactoring.
    Open

                    case TextureFormat.R32G32_UINT:
                        for (int i = 0, j = 0; i < width; i++, j = i * 4)
                        {
                            buffer[j] = input.ReadUInt32();
                            buffer[j + 1] = input.ReadUInt32();
    Severity: Major
    Found in src/Bannerlord.LauncherEx/TPac/TextureUtils.cs and 3 other locations - About 1 hr to fix
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 366..374
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 466..474
    src/Bannerlord.LauncherEx/TPac/TextureUtils.cs on lines 552..560

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

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

        private static unsafe string? InnerGet()
        {
            var handle = (HGLOBAL) IntPtr.Zero;
    
            var pointer = IntPtr.Zero;
    Severity: Minor
    Found in src/Bannerlord.LauncherEx/Helpers/Input/WindowsClipboard.cs - About 1 hr to fix

      Method TryResolveHarmonyAssembliesFileFromSteam has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static HarmonyDiscoveryResult TryResolveHarmonyAssembliesFileFromSteam(AssemblyName assemblyName, out string? path)
          {
              path = null;
              var assemblyNameFull = $"{assemblyName.Name}.dll";
      
      
      Severity: Minor
      Found in src/Bannerlord.BLSE.Shared/Utils/HarmonyFinder.cs - About 1 hr to fix

        Method ReadBC3AlphaBlock has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public static void ReadBC3AlphaBlock(long block, byte[][] cache, int posX, GetPixelMask writeMask)
                {
                    writeMask(out var maskR, out var maskG, out var maskB, out var maskA,
                        out var addR, out var addG, out var addB, out var addA);
                    var alpha0 = (int) (block & 0xFF);
        Severity: Minor
        Found in src/Bannerlord.LauncherEx/TPac/TextureUtils.cs - About 1 hr to fix

          Method RegisterPatch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static void RegisterPatch(string movie, string? xpath, PrefabExtensionInsertAsSiblingPatch patch)
              {
                  RegisterPatch(movie, xpath, node =>
                  {
                      var ownerDocument = node as XmlDocument ?? node.OwnerDocument;
          Severity: Minor
          Found in src/Bannerlord.LauncherEx/Helpers/UI/PrefabExtensionManager.cs - About 1 hr to fix

            Method TryResolveHarmonyAssembliesFile has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static HarmonyDiscoveryResult TryResolveHarmonyAssembliesFile(AssemblyName assemblyName, out string? path)
                {
                    path = null;
                    var assemblyNameFull = $"{assemblyName.Name}.dll";
            
            
            Severity: Minor
            Found in src/Bannerlord.BLSE.Shared/Utils/HarmonyFinder.cs - About 1 hr to fix

              Method TexImage2D2 has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private static extern void TexImage2D2(uint target, int level, uint pixelInternalformat, int width, int height, int border, PixelFormat format, uint type, IntPtr pixels);
              Severity: Major
              Found in src/Bannerlord.LauncherEx/Extensions/OpenGLTextureExtensions.cs - About 1 hr to fix

                Method TexImage2D has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private static extern void TexImage2D(uint target, int level, uint pixelInternalformat, int width, int height, int border, PixelFormat format, uint type, byte[] pixels);
                Severity: Major
                Found in src/Bannerlord.LauncherEx/Extensions/OpenGLTextureExtensions.cs - About 1 hr to fix

                  Method Enable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static bool Enable(Harmony harmony)
                      {
                          _harmony = harmony;
                  
                          var res1 = harmony.TryPatch(
                  Severity: Minor
                  Found in src/Bannerlord.LauncherEx/ResourceManagers/WidgetFactoryManager.cs - About 1 hr to fix

                    Method ResolveLauncherExAssemblies has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private static Assembly? ResolveLauncherExAssemblies(AssemblyName assemblyName)
                        {
                            var @namespace = "Bannerlord.BLSE.Shared.";
                            var resources = typeof(ModuleInitializer).Assembly.GetManifestResourceNames().Select(x => x.Remove(0, @namespace.Length));
                            var versions = resources.Where(x => x.StartsWith("Bannerlord.LauncherEx_")).Select(x =>
                    Severity: Minor
                    Found in src/Bannerlord.BLSE.Shared/ModuleInitializer.cs - About 1 hr to fix

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

                          protected override void OnMousePressed()
                          {
                              if (_clickState != ButtonClickState.None) return;
                      
                              _clickState = ButtonClickState.HandlingClick;
                      src/Bannerlord.LauncherEx/Widgets/LauncherToggleButtonWidget.cs on lines 176..190

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

                      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 OnMouseAlternatePressed()
                          {
                              if (_clickState != ButtonClickState.None) return;
                      
                              _clickState = ButtonClickState.HandlingAlternateClick;
                      src/Bannerlord.LauncherEx/Widgets/LauncherToggleButtonWidget.cs on lines 137..151

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

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

                              [MethodImpl(MethodImplOptions.NoInlining)]
                              static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
                              {
                                  var returnNull = new List<CodeInstruction>
                                      {
                      Severity: Minor
                      Found in src/Bannerlord.LauncherEx/Patches/WidgetPrefabPatch.cs - About 1 hr to fix

                        Method Verify has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static void Verify()
                            {
                                var assemblyFile = new FileInfo(typeof(GameConsistencyChecker).Assembly.Location);
                        
                                var platform = assemblyFile.Directory!.Name;
                        Severity: Minor
                        Found in src/Bannerlord.BLSE.Loaders.Standalone/GameConsistencyChecker.cs - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language