cs-util-com/cscore

View on GitHub

Showing 1,140 of 1,140 total issues

Method ShowUI has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private async Task ShowUI() {

            // Register the logger that looks up solutions for errors automatically:
            Log.AddLoggerToLogInstances(new LazyDeveloperLogger());

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

                for (int x = 0; x < width; ++x) {
                    for (int y = 0; y < height; ++y) {
                        if (ColorIsValue(trimap, x, y, 1))
                            SetColorAt(trimap, x, y, black);
                        else if (ColorIsValue(trimap, x, y, 254))
    CsCore/PlainNetClassLib/src/Plugins/CsCore/com/csutil/algorithms/images/GlobalMatting.cs on lines 255..262

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

    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

                for (int y = 0; y < h; ++y) {
                    for (int x = 0; x < w; ++x) {
                        if (ColorIsValue(trimap, x, y, 0))
                            SetColorAt(background, x, y, almostBlack);
                        else if (ColorIsValue(trimap, x, y, 255))
    CsCore/PlainNetClassLib/src/Plugins/CsCore/com/csutil/algorithms/images/GlobalMatting.cs on lines 236..243

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

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

            protected override void LateUpdate()
            {
                // We do  the actual internal mesh updating as late as possible so nothing ends up a frame behind
                var deltaTime = Time.deltaTime;
    
    

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

            private IndexNode AddNode(CollectionIndex index, BsonValue key, byte level, IndexNode last)
            {
                // calc key size
                var keyLength = key.GetBytesCount(false);
    
    

    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__compute_huffman_codes has a Cognitive Complexity of 27 (exceeds 20 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];

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

            private static object SetSingleton<T, V>(this Injector self, object caller, V singletonInstance, bool overrideExisting = false) where V : T {
                lock (syncLock) {
                    singletonInstance.ThrowErrorIfNull("singletonInstance");
                    if (!overrideExisting && typeof(T).IsCastableTo<IDisposableV2>()) {
                        // Cause a injector cleanup if there is a present singleton and this singleton is disposed:

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

            public void SetPositions(Vector3[] newPositions, bool knownSizeChange = false)
            {
                // Update internal data
                m_Positions = newPositions;
                if (NeedsReinitialize())

      Method ToString has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public override string ToString() {
            string coords1, coords2;
            if (this.length1 == 0) {
              coords1 = this.start1 + ",0";
            } else if (this.length1 == 1) {

        Method RunRansac has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public static M RunRansac<E, M>(this Random rnd, IEnumerable<E> e, int d, int minSampleSize, int iterations, Func<IEnumerable<E>, M> createModel, Func<M, E, bool> isInlier) where M : IModel<E> {
                    var elems = e.Cached();
                    if (minSampleSize > elems.Count()) {
                        throw new ArgumentOutOfRangeException($"minSampleSize must be smaller then nr of elements, otherwise ransac would not make sense: minSampleSize={minSampleSize} and elems.Count()={elems.Count()}");
                    }

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

                  public static UnityAction<int> SetOnValueChangedAction(this TMP_Dropdown self, Func<int, bool> onValueChanged) {
                      AssertV3.IsNotNull(self, "self (Dropdown)");
                      if (self.onValueChanged != null && self.onValueChanged.GetPersistentEventCount() > 0) {
                          Log.w("Overriding old onValueChanged listener for input field " + self, self.gameObject);
                      }
          CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs on lines 231..238

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

          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> SetOnValueChangedAction(this Dropdown self, Func<int, bool> onValueChanged) {
                      AssertV3.IsNotNull(self, "self (Dropdown)");
                      if (self.onValueChanged != null && self.onValueChanged.GetPersistentEventCount() > 0) {
                          Log.w("Overriding old onValueChanged listener for input field " + self, self.gameObject);
                      }
          CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs on lines 240..247

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

          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 (m.Groups[2].Length == 0) {
                    patch.start1--;
                    patch.length1 = 1;
                  } else if (m.Groups[2].Value == "0") {
                    patch.length1 = 0;
          CsCore/PlainNetClassLib/src/Plugins/CsCore/libs/DiffMatchPatch/DiffMatchPatch.cs on lines 2231..2239

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

          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 (m.Groups[4].Length == 0) {
                    patch.start2--;
                    patch.length2 = 1;
                  } else if (m.Groups[4].Value == "0") {
                    patch.length2 = 0;
          CsCore/PlainNetClassLib/src/Plugins/CsCore/libs/DiffMatchPatch/DiffMatchPatch.cs on lines 2220..2228

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

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

                  public static void AddRect(
                      ref VertexHelper vh,
                      Vector2 center,
                      float width,
                      float height,

            Method OnSceneViewGUI has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    [InitializeOnLoadMethod]
                    private static void OnSceneViewGUI() {
            #if UNITY_2019_1_OR_NEWER
                        SceneView.duringSceneGui += (SceneView sceneView) =>
            #else

              Method GetPropertyType has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      private static bool GetPropertyType(PropertyInfo info, out SerializedPropertyType propertyType) {
                          propertyType = SerializedPropertyType.Generic;
                          Type type = info.PropertyType;
                          if (type == typeof(int)) {
                              propertyType = SerializedPropertyType.Integer;

                Method UpdateDocument has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        private bool UpdateDocument(CollectionPage col, BsonDocument doc)
                        {
                            // normalize id before find
                            var id = doc["_id"];
                
                

                  Method Multiply has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          private static Mat<T> Multiply(Mat<T> a, Mat<T> b) {
                              if (a.Width != b.Height)
                                  throw new ArgumentException("Matrix A's width must match Matrix B's height.");
                  
                              Mat<T> result = new Mat<T>(a.Height, b.Width, 1);

                    Method HsvToRgb has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            public static float[] HsvToRgb(float hue, float saturation, float value) {
                                hue = hue.Equals(1f) ? 0f : hue * 6f;
                                var i = (int)hue;
                                var r = value;
                                var g = value;
                      Severity
                      Category
                      Status
                      Source
                      Language