gitlabhq/gitlabhq

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

Summary

Maintainability
D
2 days
Test Coverage

Class Converter has 77 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

    File ansi2html.rb has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Gitlab
      module Ci
        module Ansi2html
          # keys represent the trailing digit in color changing command (30-37, 40-47, 90-97. 100-107)
          COLOR = {
    Severity: Minor
    Found in lib/gitlab/ci/ansi2html.rb - About 3 hrs to fix

      Method open_new_tag has a Cognitive Complexity of 14 (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 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 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 42 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 28 lines of code (exceeds 25 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 1 hr to fix

          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

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

                  def handle_section_end(section, timestamp)
                    return unless @sections.include?(section)
          
                    # close all sections up to section
                    until @sections.empty?
          Severity: Minor
          Found in lib/gitlab/ci/ansi2html.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

          Similar blocks of code found in 2 locations. 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 and 1 other location - About 35 mins to fix
          lib/gitlab/ci/ansi2json/parser.rb on lines 179..190

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 36.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          There are no issues that match your filters.

          Category
          Status