hugopl/reviewit

View on GitHub
app/models/diff.rb

Summary

Maintainability
C
1 day
Test Coverage

Method start_reading_interdiff_file_metadata has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def start_reading_interdiff_file_metadata(line)
    new_file_line = line =~ /^(diff -u|---|\+\+\+)/
    interdiff_tag = line =~ /^(reverted|unchanged|only in patch2|only in patch1)/
    return false if !new_file_line && !interdiff_tag

Severity: Minor
Found in app/models/diff.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 path_diff has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def path_diff(from, to)
      old_parts = from.split('/')
      new_parts = to.split('/')
      output = []
      old_changed = []
Severity: Minor
Found in app/models/diff.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

File diff.rb has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Diff
  # Source can be :git or :interdiff
  def initialize(diff, source: :git)
    @raw = diff
    @files = {}
Severity: Minor
Found in app/models/diff.rb - About 2 hrs to fix

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

        def path_diff(from, to)
          old_parts = from.split('/')
          new_parts = to.split('/')
          output = []
          old_changed = []
    Severity: Minor
    Found in app/models/diff.rb - About 1 hr to fix

      Method start_reading_interdiff_file_metadata has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def start_reading_interdiff_file_metadata(line)
          new_file_line = line =~ /^(diff -u|---|\+\+\+)/
          interdiff_tag = line =~ /^(reverted|unchanged|only in patch2|only in patch1)/
          return false if !new_file_line && !interdiff_tag
      
      
      Severity: Minor
      Found in app/models/diff.rb - About 1 hr to fix

        Method each_change has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def each_change
              old_ln = old_ln_cache = 0
              new_ln = new_ln_cache = 0
        
              @changes.each_with_index do |line, i|
        Severity: Minor
        Found in app/models/diff.rb - About 1 hr to fix

          Method state_reading_file_metadata has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def state_reading_file_metadata(line)
              case line
              when /^new file mode (.+)/
                @file.status = :new
                @file.new_chmod = $1
          Severity: Minor
          Found in app/models/diff.rb - About 1 hr to fix

            There are no issues that match your filters.

            Category
            Status