cs-util-com/cscore

View on GitHub

Showing 1,140 of 1,140 total issues

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

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

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

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

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

            private JArray ArrayUnpatch(JArray right, JObject patch)
            {
                var toRemove = new List<JProperty>();
                var toInsert = new List<JProperty>();
                var toModify = new List<JProperty>();

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

          public class TaskV2 {
      
              private static int lastOverhead = 0;
      
              public static Task Delay(int millisecondsDelay) { return Delay(millisecondsDelay, CancellationToken.None); }
      Severity: Minor
      Found in CsCore/PlainNetClassLib/src/Plugins/CsCore/com/csutil/async/TaskV2.cs - About 2 hrs to fix

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

            public class Headers : IEnumerable<KeyValuePair<string, IEnumerable<string>>> {
        
                private Dictionary<string, IEnumerable<string>> headers = new Dictionary<string, IEnumerable<string>>();
        
                public Headers(IEnumerable<KeyValuePair<string, string>> headers) { AddRange(headers); }
        Severity: Minor
        Found in CsCore/PlainNetClassLib/src/Plugins/CsCore/com/csutil/http/Headers.cs - About 2 hrs to fix

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

              public class ModelToJsonSchema {
          
                  public JsonSerializer jsonSerializer;
                  /// <summary>
                  /// If true and the view model is derived from an model instance,   

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

                public class TemplatesIO<T> : IDisposableV2 where T : IEntityData {
            
                    public DisposeState IsDisposed { get; private set; } = DisposeState.Active;
            
                    private readonly DirectoryEntry _entityDir;

              Method patch_make has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public List<Patch> patch_make(string text1, List<Diff> diffs) {
                    // Check for null inputs not needed since null can't be passed in C#.
                    List<Patch> patches = new List<Patch>();
                    if (diffs.Count == 0) {
                      return patches;  // Get rid of the null case.

                Method Patch has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Method stbi__jpeg_decode_block has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          private int stbi__jpeg_decode_block(short[] data, stbi__huffman hdc, stbi__huffman hac, short[] fac, int b,
                              ushort[] dequant)
                          {
                              var diff = 0;
                              var dc = 0;

                    Method GlobalMattingHelper has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            private void GlobalMattingHelper(byte[] trimap, out byte[] foreground, out byte[] alpha, out byte[] conf) {
                                var t = Log.MethodEntered();
                                var foregroundBoundary = FindBoundaryPixels(trimap, 255, 128);
                                var backgroundBoundary = FindBoundaryPixels(trimap, 0, 128);
                    
                    

                      Method DoPropagateIteration has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              private void DoPropagateIteration(byte[] trimap, List<Point> foregroundBoundary, List<Point> backgroundBoundary, Sample[][] samples, int w, int h) {
                      
                                  // Create and shuffle coordinate points
                                  List<Point> coords1 = new List<Point>(h * w);
                                  for (int y = 0; y < h; ++y)

                        Method AddRectRing has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                public static void AddRectRing(
                                    ref VertexHelper vh,
                                    UI.GeoUtils.OutlineProperties OutlineProperties,
                                    Vector2 center,
                                    float width,

                          Method diff_cleanupEfficiency has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public void diff_cleanupEfficiency(List<Diff> diffs) {
                                bool changes = false;
                                // Stack of indices where equalities are found.
                                Stack<int> equalities = new Stack<int>();
                                // Always equal to equalities[equalitiesLength-1][1]

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

                                    public static void SetOptionsEnum<T>(this TMP_Dropdown dropdown, T currentSelection, Func<T, bool> onValueChanged, string[] textsToShow = null) where T : Enum {
                                        string[] names = Enum.GetNames(typeof(T));
                                        if (textsToShow == null) { textsToShow = names; }
                                        dropdown.SetOptions(textsToShow, names.IndexOf(currentSelection.ToString()));
                                        dropdown.SetOnValueChangedAction(i => {
                            CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs on lines 208..215

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

                            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 void SetOptionsEnum<T>(this Dropdown dropdown, T currentSelection, Func<T, bool> onValueChanged, string[] textsToShow = null) where T : Enum {
                                        string[] names = Enum.GetNames(typeof(T));
                                        if (textsToShow == null) { textsToShow = names; }
                                        dropdown.SetOptions(textsToShow, names.IndexOf(currentSelection.ToString()));
                                        dropdown.SetOnValueChangedAction(i => {
                            CsCore/CsCoreUnity/Plugins/CsCoreUnity/com/csutil/ui/UiExtensions.cs on lines 222..229

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

                            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 AddRoundedRectVerticesRing has 18 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                        ref VertexHelper vh,
                                        Vector2 center,
                                        float width,
                                        float height,
                                        float fullWidth,

                              Method patch_fromText has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
                              Open

                                  public List<Patch> patch_fromText(string textline) {
                                    List<Patch> patches = new List<Patch>();
                                    if (textline.Length == 0) {
                                      return patches;
                                    }

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

                                      internal BsonValue Serialize(Type type, object obj, int depth)
                                      {
                                          if (++depth > MAX_DEPTH) throw UltraLiteException.DocumentMaxDepth(MAX_DEPTH, type);
                              
                                          if (obj == null) return BsonValue.Null;

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

                                      private int stbi__process_scan_header()
                                      {
                                          var i = 0;
                                          var Ls = stbi__get16be();
                                          scan_n = stbi__get8();

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language