cs-util-com/cscore

View on GitHub

Showing 1,140 of 1,140 total issues

Method ReadElement has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private static BsonValue ReadElement(ByteReader reader, out string name, bool utcDate)
        {
            var type = reader.ReadByte();
            name = reader.ReadCString();

    Method stbi__create_png_image has 71 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            private int stbi__create_png_image(FakePtr<byte> image_data, uint image_data_len, int out_n, int depth,
                int color, int interlaced)
            {
                var bytes = depth == 16 ? 2 : 1;
                var out_bytes = out_n * bytes;

      Method Set has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public static void Set(this ref Matrix4x4 self, int rowIndex, int columnIndex, float value) {
                  if (rowIndex < 0 || rowIndex > 3 || columnIndex < 0 || columnIndex > 3) {
                      throw new ArgumentOutOfRangeException("Row and column indices must be between 0 and 3 inclusive.");
                  }
                  switch (rowIndex) {

        Class EventBusUnityExtensions has 25 methods (exceeds 20 allowed). Consider refactoring.
        Open

            public static class EventBusUnityExtensions {
        
                public static void Subscribe(this Behaviour b, string eventName, Action callback) {
                    EventBus.instance.SubscribeMono(b, eventName, callback);
                }

          Class ByteReader has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

              public class ByteReader
              {
                  private byte[] _buffer;
                  private int _length;
                  private int _pos;

            File QueuedTaskScheduler.cs has 284 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            using System.Collections.Concurrent;
            using System.Collections.Generic;
            using System.Linq;
            
            namespace System.Threading.Tasks.Schedulers {

              Method Serialize has 70 lines of code (exceeds 25 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;

                Method match_bitap has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected int match_bitap(string text, string pattern, int loc) {
                      // assert (Match_MaxBits == 0 || pattern.Length <= Match_MaxBits)
                      //    : "Pattern too long for this application.";
                
                      // Initialise the alphabet.

                  Method NewField has 70 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          public virtual JsonSchema NewField(string name, Type parentType, object pInstance = null, JToken jpInstance = null) {
                              MemberInfo model = parentType?.GetMember(name).First();
                              Type modelType = GetModelType(model);
                              JTokenType jTokenType = ToJTokenType(modelType, jpInstance);
                              AssertV3.IsNotNull(jTokenType, "jTokenType");

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

                            private static string CalcMultiLineUnequalText<T>(IEnumerable<T> expected, IEnumerable<T> actual, string _ = LB + "   ") {
                                int diffPos = GetPosOfFirstDiff(expected, actual);
                                int spacesCount = diffPos - 1;
                                if (!(expected is string)) { spacesCount = spacesCount * 3 + 1; }
                                string spaces = new string(' ', spacesCount);
                    CsCore/PlainNetClassLib/src/Plugins/CsCore/com/csutil/logging/AssertV2.cs on lines 117..126

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

                    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

                            private static string CalcMultiLineUnequalText<T>(IEnumerable<T> expected, IEnumerable<T> actual, string _ = LB + "   ") {
                                int diffPos = GetPosOfFirstDiff(expected, actual);
                                int spacesCount = diffPos - 1;
                                if (!(expected is string)) { spacesCount = spacesCount * 3 + 1; }
                                string spaces = new string(' ', spacesCount);
                    CsCore/PlainNetClassLib/src/Plugins/CsCore/com/csutil/logging/AssertV3.cs on lines 112..121

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

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

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

                      Method Test has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
                      Open

                              public static bool Test(Stream stream)
                              {
                                  try
                                  {
                                      stream.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

                      Class ColorUtil has 24 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                          public static class ColorUtil {
                      
                              /// <summary> All channels must be between 0 and 255 </summary>
                              public static Color32 With(this Color32 c, int r = -1, int g = -1, int b = -1, int a = -1) {
                                  return new Color32(r < 0 ? c.r : (byte)r, g < 0 ? c.g : (byte)g, b < 0 ? c.b : (byte)b, a < 0 ? c.a : (byte)a);

                        Class UltraLiteException has 24 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                            public class UltraLiteException : Exception
                            {
                                #region Errors code
                        
                                public const int FILE_NOT_FOUND = 101;

                          Class Injector has 24 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                              public class Injector {
                          
                                  public static Injector newInjector(IEventBus eventbusToUse) { return new Injector { usedEventBus = eventbusToUse }; }
                          
                                  public IEventBus usedEventBus = EventBus.instance;

                            Class GlobalMatting has 24 methods (exceeds 20 allowed). Consider refactoring.
                            Open

                                public class GlobalMatting {
                            
                                    private readonly byte[] black = new byte[] { 0, 0, 0, 0 };
                                    private readonly byte[] almostBlack = new byte[] { 1, 1, 1, 1 };
                                    private readonly byte[] gray = new byte[] { 128, 128, 128, 128 };

                              Method LinkToJsonModel has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      public static bool LinkToJsonModel(this FieldView self, JObject root, JToken value) {
                                          if (self is EnumFieldView enumFieldView && value?.Type == JTokenType.Integer) {
                                              int posInEnum = int.Parse("" + value);
                                              var enumValues = self.field.contentEnum;
                                              enumFieldView.LinkToModel(enumValues[posInEnum], newVal => {

                                Method stbi__parse_huffman_block has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                        private int stbi__parse_huffman_block()
                                        {
                                            var zout = this.zout;
                                            for (; ; )
                                            {

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

                                          public static object CreateInstance(Type type)
                                          {
                                              try
                                              {
                                                  if (_cacheCtor.TryGetValue(type, out CreateObject c))

                                  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