rlqualls/sugarcane

View on GitHub

Showing 11 of 13 total issues

Method run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      if @data.nil? or @data.empty?
        return nil
      end
      begin
Severity: Minor
Found in lib/sugarcane/menu.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

Class DocCheck has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

  class DocCheck < Struct.new(:opts)

    DESCRIPTION =
    "Class and Module definitions require explanatory comments on previous line"

Severity: Minor
Found in lib/sugarcane/doc_check.rb - About 2 hrs to fix

    Method draw_menu has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def draw_menu(menu, active_index=nil)
          Ncurses.stdscr.border(*([0]*8))
          Ncurses.stdscr.refresh
          menu.clear
          menu.border(*([0]*8))
    Severity: Minor
    Found in lib/sugarcane/menu.rb - About 1 hr to fix

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

          def run
            if @data.nil? or @data.empty?
              return nil
            end
            begin
      Severity: Minor
      Found in lib/sugarcane/menu.rb - About 1 hr to fix

        Method process_ast has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def process_ast(node, complexity = {}, nesting = [])
                if method_nodes.include?(node[0])
                  nesting = nesting + [label_for(node)]
                  desc = method_description(node, *nesting)
                  unless excluded?(desc)
        Severity: Minor
        Found in lib/sugarcane/abc_check.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 draw_menu has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def draw_menu(menu, active_index=nil)
              Ncurses.stdscr.border(*([0]*8))
              Ncurses.stdscr.refresh
              menu.clear
              menu.border(*([0]*8))
        Severity: Minor
        Found in lib/sugarcane/menu.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def initialize(task_name = nil)
              self.name = task_name || :cane
              @gte = []
              @options = SugarCane::CLI.default_options
              @options[:report] = true
        Severity: Minor
        Found in lib/sugarcane/rake_task.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 class_definitions_in has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def class_definitions_in(file_name)
              closed_classes = []
              open_classes = []
              last_line = ""
        
        
        Severity: Minor
        Found in lib/sugarcane/doc_check.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 edit_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def edit_file(file, line)
              if @options[:editor]
                system("#{@options[:editor]} +#{line} #{file}")
              # If someone purchased sublime, they probably want to use it
              elsif program_exist? "subl"
        Severity: Minor
        Found in lib/sugarcane/menu.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 container_label has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def container_label(node)
                if container_nodes.include?(node[0])
                  # def foo, def self.foo
                  node[1][-1][1]
                elsif node[0] == :method_add_block
        Severity: Minor
        Found in lib/sugarcane/abc_check.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 add_check_options has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def add_check_options(check)
                check.options.each do |key, data|
                  cli_key  = key.to_s.tr('_', '-')
                  opts     = data[1] || {}
                  variable = opts[:variable] || "VALUE"
        Severity: Minor
        Found in lib/sugarcane/cli/parser.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

        Severity
        Category
        Status
        Source
        Language