app/models/diff.rb
Method start_reading_interdiff_file_metadata
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
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
- Read upRead up
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
Open
def path_diff(from, to)
old_parts = from.split('/')
new_parts = to.split('/')
output = []
old_changed = []
- Read upRead up
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
Open
class Diff
# Source can be :git or :interdiff
def initialize(diff, source: :git)
@raw = diff
@files = {}
Method path_diff
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def path_diff(from, to)
old_parts = from.split('/')
new_parts = to.split('/')
output = []
old_changed = []
Method start_reading_interdiff_file_metadata
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Method each_change
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def each_change
old_ln = old_ln_cache = 0
new_ln = new_ln_cache = 0
@changes.each_with_index do |line, i|
Method state_reading_file_metadata
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
def state_reading_file_metadata(line)
case line
when /^new file mode (.+)/
@file.status = :new
@file.new_chmod = $1