rlqualls/sugarcane

View on GitHub

Showing 13 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def self.options
              {
                abc_glob: ['Glob to run ABC metrics over',
                              default: '{app,lib}/**/*.rb',
                              variable: 'GLOB',
        Severity: Minor
        Found in lib/sugarcane/abc_check.rb and 1 other location - About 55 mins to fix
        lib/sugarcane/style_check.rb on lines 16..32

        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 46.

        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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            def self.options
              {
                style_glob:    ['Glob to run style checks over',
                                   default:  '{app,lib,spec}/**/*.rb',
                                   variable: 'GLOB',
        Severity: Minor
        Found in lib/sugarcane/style_check.rb and 1 other location - About 55 mins to fix
        lib/sugarcane/abc_check.rb on lines 17..34

        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 46.

        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

        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 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 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 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 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