gitlabhq/gitlabhq

View on GitHub
lib/gitlab/conflict/file.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method sections has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def sections
        return @sections if @sections

        chunked_lines = lines.chunk { |line| line.type.nil? }.to_a
        match_line = nil
Severity: Minor
Found in lib/gitlab/conflict/file.rb - About 3 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 sections has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def sections
        return @sections if @sections

        chunked_lines = lines.chunk { |line| line.type.nil? }.to_a
        match_line = nil
Severity: Minor
Found in lib/gitlab/conflict/file.rb - About 1 hr to fix

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

          def find_match_line_header(index)
            return @match_line_headers[index] if @match_line_headers.key?(index)
    
            @match_line_headers[index] = begin
              if index >= 0
    Severity: Minor
    Found in lib/gitlab/conflict/file.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 as_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def as_json(opts = {})
            json_hash = {
              old_path: their_path,
              new_path: our_path,
              blob_icon: file_type_icon_class('file', our_mode, our_path),
    Severity: Minor
    Found in lib/gitlab/conflict/file.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