cs-util-com/cscore

View on GitHub

Showing 1,140 of 1,140 total issues

Method Patch has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
Open

        public JToken Patch(JToken left, JToken patch)
        {
            if (patch == null)
                return left;

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 stbi__decode_jpeg_image has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
Open

        private int stbi__decode_jpeg_image()
        {
            var m = 0;
            for (m = 0; m < 4; m++)
            {

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

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

            for (int i = 0; i < cornerUnitPositions.BLUnitPositions.Length; i++)
            {
                tmpPos.x = tmpV3.x + cornerUnitPositions.BLUnitPositions[i].x * blOuterRadius;
                tmpPos.y = tmpV3.y + cornerUnitPositions.BLUnitPositions[i].y * blOuterRadius;
                tmpPos.z = tmpV3.z;
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 515..525
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 539..549
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 587..597

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

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

            for (int i = 0; i < cornerUnitPositions.BRUnitPositions.Length; i++)
            {
                tmpPos.x = tmpV3.x + cornerUnitPositions.BRUnitPositions[i].x * brOuterRadius;
                tmpPos.y = tmpV3.y + cornerUnitPositions.BRUnitPositions[i].y * brOuterRadius;
                tmpPos.z = tmpV3.z;
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 515..525
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 563..573
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 587..597

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

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

            for (int i = 0; i < cornerUnitPositions.TRUnitPositions.Length; i++)
            {
                tmpPos.x = tmpV3.x + cornerUnitPositions.TRUnitPositions[i].x * trOuterRadius;
                tmpPos.y = tmpV3.y + cornerUnitPositions.TRUnitPositions[i].y * trOuterRadius;
                tmpPos.z = tmpV3.z;
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 539..549
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 563..573
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 587..597

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

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

            for (int i = 0; i < cornerUnitPositions.TLUnitPositions.Length; i++)
            {
                tmpPos.x = tmpV3.x + cornerUnitPositions.TLUnitPositions[i].x * tlOuterRadius;
                tmpPos.y = tmpV3.y + cornerUnitPositions.TLUnitPositions[i].y * tlOuterRadius;
                tmpPos.z = tmpV3.z;
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 515..525
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 539..549
CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/UiShapes/RoundedRects.cs on lines 563..573

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

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

        private JObject ArrayDiff(JArray left, JArray right)
        {
            var result = JObject.Parse(@"{ ""_t"": ""a"" }");

            int commonHead = 0;

    File UiExtensions.cs has 272 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    using com.csutil.ui;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    Severity: Minor
    Found in CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs - About 2 hrs to fix

      Class ByteWriter has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

          public class ByteWriter
          {
              private byte[] _buffer;
              private int _pos;
      
      

        Class Query has 23 methods (exceeds 20 allowed). Consider refactoring.
        Open

            public abstract class Query
            {
                public string Field { get; private set; }
        
                internal BsonFields Expression { get; set; }

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

                  public Task<bool> TryLockAsync(Action callback, CancellationToken cancel)
                  {
                      var @lock = new InnerLock(this, _asyncId.Value, ThreadId);
                      _asyncId.Value = Interlocked.Increment(ref AsyncLock.AsyncStackCounter);
          
          
          CsCore/PlainNetClassLib/src/Plugins/CsCore/libs/AsyncLock/AsyncLock.cs on lines 337..365

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

          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 Task<bool> TryLockAsync(Action callback, TimeSpan timeout)
                  {
                      var @lock = new InnerLock(this, _asyncId.Value, ThreadId);
                      _asyncId.Value = Interlocked.Increment(ref AsyncLock.AsyncStackCounter);
          
          
          CsCore/PlainNetClassLib/src/Plugins/CsCore/libs/AsyncLock/AsyncLock.cs on lines 404..432

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

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

                  public static ImageInfo? Info(Stream stream)
                  {
                      try
                      {
                          var tga_w = 0;

            Method Initialize has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    protected override void Initialize(bool setMesh = true)
                    {
                        base.Initialize();
                        CopyWorldSpaceDataFromMaterial();
            
            

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

                      public static UnityAction<string> AddOnValueChangedAction(this TMP_InputField self, Func<string, bool> onValueChanged, bool skipChangesByLogic = true) {
                          if (self.IsNullOrDestroyed()) {
                              throw new ArgumentNullException("self (InputField)");
                          }
                          if (onValueChanged != null) {
              CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiInputFieldExtensions.cs on lines 112..133

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

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

                      public static UnityAction<string> AddOnValueChangedAction(this InputField self, Func<string, bool> onValueChanged, bool skipChangesByLogic = true) {
                          if (self.IsNullOrDestroyed()) {
                              throw new ArgumentNullException("self (InputField)");
                          }
                          if (onValueChanged != null) {
              CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiInputFieldExtensions.cs on lines 88..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 176.

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

                      private int stbi__compute_huffman_codes()
                      {
                          var z_codelength = new stbi__zhuffman();
                          var lencodes = new byte[286 + 32 + 137];
                          var codelength_sizes = new byte[19];

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

                        public static async Task<bool> Show(string caption, string message, string confirmBtnText = null, string dialogPrefabName = "Dialogs/DefaultDialog2", string cancelBtnText = null) {
                            if (!ApplicationV2.isPlaying) {
                                throw new System.NotSupportedException("Showing dialogs are only supported in play mode");
                            }
                            var loader = new DialogLoader<ConfirmCancelDialog>(new ConfirmCancelDialog(caption, message, confirmBtnText, cancelBtnText));
                CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/Components/Dialog/DialogForTextInput.cs on lines 32..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 172.

                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 static UnityAction<int> AddOnValueChangedAction(this TMP_Dropdown self, Func<int, bool> onValueChanged) {
                            if (onValueChanged != null) {
                                var oldSelection = self.value;
                                UnityAction<int> newListener = (newSection) => {
                                    if (newSection == oldSelection) { return; }
                CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs on lines 249..267

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

                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 static UnityAction<int> AddOnValueChangedAction(this Dropdown self, Func<int, bool> onValueChanged) {
                            if (onValueChanged != null) {
                                var oldSelection = self.value;
                                UnityAction<int> newListener = (newSection) => {
                                    if (newSection == oldSelection) { return; }
                CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs on lines 269..287

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

                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