gitlabhq/gitlabhq

View on GitHub
lib/gitlab/ci/ansi2html.rb

Summary

Maintainability
D
1 day
Test Coverage

Class Converter has 69 methods (exceeds 20 allowed). Consider refactoring.
Open

      class Converter
        def on_0(_) reset                              end

        def on_1(_) enable(STYLE_SWITCHES[:bold])      end

Severity: Major
Found in lib/gitlab/ci/ansi2html.rb - About 1 day to fix

    Method convert has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def convert(stream, new_state)
              reset_state
              restore_state(new_state, stream) if new_state.present?
    
              append = false
    Severity: Minor
    Found in lib/gitlab/ci/ansi2html.rb - About 1 hr 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 convert has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def convert(stream, new_state)
              reset_state
              restore_state(new_state, stream) if new_state.present?
    
              append = false
    Severity: Minor
    Found in lib/gitlab/ci/ansi2html.rb - About 1 hr to fix

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

              def open_new_tag
                css_classes = []
      
                unless @fg_color.nil?
                  fg_color = @fg_color
      Severity: Minor
      Found in lib/gitlab/ci/ansi2html.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 get_xterm_color_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_xterm_color_class(command_stack, prefix)
                # the 38 and 48 commands have to be followed by "5" and the color index
                return unless command_stack.length >= 2
                return unless command_stack[0] == "5"
      
      
      Severity: Minor
      Found in lib/gitlab/ci/ansi2html.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

      There are no issues that match your filters.

      Category
      Status