gabynaiman/timing

View on GitHub

Showing 152 of 152 total issues

Avoid deeply nested control flow statements.
Open

                if r11
                  s10 << r11
                else
                  break
                end
Severity: Major
Found in lib/timing/natural_time_language.rb - About 45 mins to fix

    Method _nt_tomorrow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _nt_tomorrow
          start_index = index
          if node_cache[:tomorrow].has_key?(index)
            cached = node_cache[:tomorrow][index]
            if cached
    Severity: Minor
    Found in lib/timing/natural_time_language.rb - About 45 mins to fix

    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

    Avoid deeply nested control flow statements.
    Open

                  if has_terminal?('thursday', false, index)
                    r5 = instantiate_node(DayName,input, index...(index + 8))
                    @index += 8
                  else
                    terminal_parse_failure('thursday')
    Severity: Major
    Found in lib/timing/natural_time_language.rb - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                    if r5
                      r0 = r5
                    else
                      if has_terminal?('friday', false, index)
                        r6 = instantiate_node(DayName,input, index...(index + 6))
      Severity: Major
      Found in lib/timing/natural_time_language.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        if s10.size == 2
                          break
                        end
        Severity: Major
        Found in lib/timing/natural_time_language.rb - About 45 mins to fix

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

                        if r7
                          s8, i8 = [], index
                          loop do
                            r9 = _nt_space
                            if r9
          Severity: Major
          Found in lib/timing/natural_time_language.rb and 2 other locations - About 45 mins to fix
          lib/timing/natural_time_language.rb on lines 531..545
          lib/timing/natural_time_language.rb on lines 684..698

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

          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

          Avoid deeply nested control flow statements.
          Open

                        if r5
                          r0 = r5
                        else
                          @index = i0
                          r0 = nil
          Severity: Major
          Found in lib/timing/natural_time_language.rb - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                          if r7
                            s8, i8 = [], index
                            loop do
                              r9 = _nt_space
                              if r9
            Severity: Major
            Found in lib/timing/natural_time_language.rb - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                              if s7.size == 2
                                break
                              end
              Severity: Major
              Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if has_terminal?('may', false, index)
                                r5 = instantiate_node(MonthName,input, index...(index + 3))
                                @index += 3
                              else
                                terminal_parse_failure('may')
                Severity: Major
                Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                if r8
                                  r7 = r8
                                else
                                  r7 = instantiate_node(SyntaxNode,input, index...index)
                                end
                  Severity: Major
                  Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                    Method _nt_next has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _nt_next
                          start_index = index
                          if node_cache[:next].has_key?(index)
                            cached = node_cache[:next][index]
                            if cached
                    Severity: Minor
                    Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                    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

                    Avoid deeply nested control flow statements.
                    Open

                                  if r8
                                    r7 = r8
                                  else
                                    r7 = instantiate_node(SyntaxNode,input, index...index)
                                  end
                    Severity: Major
                    Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                      if has_terminal?('\G[\\d]', true, index)
                                        r8 = true
                                        @index += 1
                                      else
                                        r8 = nil
                      Severity: Major
                      Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if s7.size < 2
                                        @index = i7
                                        r7 = nil
                                      else
                                        r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
                        Severity: Major
                        Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if has_terminal?('thu', false, index)
                                          r5 = instantiate_node(DayName,input, index...(index + 3))
                                          @index += 3
                                        else
                                          terminal_parse_failure('thu')
                          Severity: Major
                          Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            if has_terminal?('\G[\\d]', true, index)
                                              r11 = true
                                              @index += 1
                                            else
                                              r11 = nil
                            Severity: Major
                            Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                              Method _nt_today has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  def _nt_today
                                    start_index = index
                                    if node_cache[:today].has_key?(index)
                                      cached = node_cache[:today][index]
                                      if cached
                              Severity: Minor
                              Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                              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

                              Avoid deeply nested control flow statements.
                              Open

                                              if r8
                                                s7 << r8
                                              else
                                                break
                                              end
                              Severity: Major
                              Found in lib/timing/natural_time_language.rb - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                              if r5
                                                r0 = r5
                                              else
                                                r6 = _nt_month_interval
                                                if r6
                                Severity: Major
                                Found in lib/timing/natural_time_language.rb - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language