CORE-POS/IS4C

View on GitHub
pos/is4c-nf/scale-drivers/drivers/NewMagellan/Newtonsoft.Json/Utilities/DateTimeUtils.cs

Summary

Maintainability
F
3 days
Test Coverage

File DateTimeUtils.cs has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

using System;
using System.IO;
using System.Xml;
using System.Globalization;

    Method TryParseDateIso has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            internal static bool TryParseDateIso(string text, DateParseHandling dateParseHandling, DateTimeZoneHandling dateTimeZoneHandling, out object dt)
            {
                DateTimeParser dateTimeParser = new DateTimeParser();
                if (!dateTimeParser.Parse(text))
                {

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

          internal static class DateTimeUtils
          {
              internal static readonly long InitialJavaScriptDateTicks = 621355968000000000;
      
              private const int DaysPer100Years = 36524;

        Method TryParseDateIso has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
        Open

                internal static bool TryParseDateIso(string text, DateParseHandling dateParseHandling, DateTimeZoneHandling dateTimeZoneHandling, out object dt)
                {
                    DateTimeParser dateTimeParser = new DateTimeParser();
                    if (!dateTimeParser.Parse(text))
                    {

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

                private static bool TryParseDateMicrosoft(string text, DateParseHandling dateParseHandling, DateTimeZoneHandling dateTimeZoneHandling, out object dt)
                {
                    string value = text.Substring(6, text.Length - 8);
                    DateTimeKind kind = DateTimeKind.Utc;
        
        

          Method WriteDateTimeString has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  internal static int WriteDateTimeString(char[] chars, int start, DateTime value, TimeSpan? offset, DateTimeKind kind, DateFormatHandling format)
                  {
                      int pos = start;
          
                      if (format == DateFormatHandling.MicrosoftDateFormat)

            Method WriteDefaultIsoDate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    internal static int WriteDefaultIsoDate(char[] chars, int start, DateTime dt)
                    {
                        int length = 19;
            
                        int year;

              Method TryParseDateTime has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
              Open

                      internal static bool TryParseDateTime(string s, DateParseHandling dateParseHandling, DateTimeZoneHandling dateTimeZoneHandling, string dateFormatString, CultureInfo culture, out object dt)
                      {
                          if (s.Length > 0)
                          {
                              if (s[0] == '/')

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

                      private static void GetDateValues(DateTime td, out int year, out int month, out int day)
                      {
                          long ticks = td.Ticks;
                          // n = number of days since 1/1/0001
                          int n = (int)(ticks / TicksPerDay);

                Method WriteDateTimeString has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        internal static int WriteDateTimeString(char[] chars, int start, DateTime value, TimeSpan? offset, DateTimeKind kind, DateFormatHandling format)

                  Method TryParseDateExact has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          private static bool TryParseDateExact(string text, DateParseHandling dateParseHandling, DateTimeZoneHandling dateTimeZoneHandling, string dateFormatString, CultureInfo culture, out object dt)

                    Method TryParseDateTime has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            internal static bool TryParseDateTime(string s, DateParseHandling dateParseHandling, DateTimeZoneHandling dateTimeZoneHandling, string dateFormatString, CultureInfo culture, out object dt)

                      Method WriteDateTimeOffsetString has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              internal static void WriteDateTimeOffsetString(TextWriter writer, DateTimeOffset value, DateFormatHandling format, string formatString, CultureInfo culture)

                        Method WriteDateTimeString has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                                internal static void WriteDateTimeString(TextWriter writer, DateTime value, DateFormatHandling format, string formatString, CultureInfo culture)

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

                                              case ParserTimeZone.LocalWestOfUtc:
                                              {
                                                  TimeSpan offset = new TimeSpan(dateTimeParser.ZoneHour, dateTimeParser.ZoneMinute, 0);
                                                  ticks = d.Ticks + offset.Ticks;
                                                  if (ticks <= DateTime.MaxValue.Ticks)
                          pos/is4c-nf/scale-drivers/drivers/NewMagellan/Newtonsoft.Json/Utilities/DateTimeUtils.cs on lines 262..279

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

                          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

                                              case ParserTimeZone.LocalEastOfUtc:
                                              {
                                                  TimeSpan offset = new TimeSpan(dateTimeParser.ZoneHour, dateTimeParser.ZoneMinute, 0);
                                                  ticks = d.Ticks - offset.Ticks;
                                                  if (ticks >= DateTime.MinValue.Ticks)
                          pos/is4c-nf/scale-drivers/drivers/NewMagellan/Newtonsoft.Json/Utilities/DateTimeUtils.cs on lines 244..261

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

                          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

                          There are no issues that match your filters.

                          Category
                          Status