redmine/redmine

View on GitHub
lib/redmine/diff_table.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method file_name= has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def file_name=(arg)
      both_git_diff = false
      if file_name.nil?
        @git_diff = true if %r{^(a/|/dev/null)}.match?(arg)
      else
Severity: Minor
Found in lib/redmine/diff_table.rb - About 2 hrs 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

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

    def parse_line(line, type="inline")
      if line.start_with?('+')
        diff = diff_for_added_line
        diff.line_right = line[1..-1]
        diff.nb_line_right = @line_num_r
Severity: Minor
Found in lib/redmine/diff_table.rb - About 1 hr to fix

    Method offsets has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def offsets(line_left, line_right)
          if line_left.present? && line_right.present? && line_left != line_right
            max = [line_left.size, line_right.size].min
            starting = 0
            while starting < max &&
    Severity: Minor
    Found in lib/redmine/diff_table.rb - About 55 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

    Method add_line has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_line(line)
          unless @parsing
            if line =~ /^(---|\+\+\+) (.*)$/
              self.file_name = $2
            elsif line =~ /^@@ (\+|\-)(\d+)(,\d+)? (\+|\-)(\d+)(,\d+)? @@/
    Severity: Minor
    Found in lib/redmine/diff_table.rb - About 35 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

    Method parse_line has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_line(line, type="inline")
          if line.start_with?('+')
            diff = diff_for_added_line
            diff.line_right = line[1..-1]
            diff.nb_line_right = @line_num_r
    Severity: Minor
    Found in lib/redmine/diff_table.rb - About 35 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

    Method write_offsets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_offsets
          if @added > 0 && @added == @removed
            @added.times do |i|
              line = self[-(1 + i)]
              removed = (@type == 'sbs') ? line : self[-(1 + @added + i)]
    Severity: Minor
    Found in lib/redmine/diff_table.rb - About 25 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

    There are no issues that match your filters.

    Category
    Status