realityforge/knife-cookbook-doc

View on GitHub

Showing 8 of 8 total issues

Class ReadmeModel has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

  class ReadmeModel
    DEFAULT_CONSTRAINT = ">= 0.0.0".freeze

    attr_reader :libraries

Severity: Minor
Found in lib/knife_cookbook_doc/readme_model.rb - About 2 hrs to fix

    Method initialize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(cookbook_dir, config)
    
          @metadata = Chef::Cookbook::Metadata.new
          @metadata.from_file("#{cookbook_dir}/#{config[:metadata]}")
    
    
    Severity: Minor
    Found in lib/knife_cookbook_doc/readme_model.rb - About 1 hr to fix

      Method initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize(cookbook_dir, config)
      
            @metadata = Chef::Cookbook::Metadata.new
            @metadata.from_file("#{cookbook_dir}/#{config[:metadata]}")
      
      
      Severity: Minor
      Found in lib/knife_cookbook_doc/readme_model.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 load_properties has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_properties
            code = IO.read(@filename)
            code.gsub(/^ *define (.*?) (?=do)/m) do
              all = $1.split(' ', 2)
              @name = all.shift.gsub(/:|,/, '')
      Severity: Minor
      Found in lib/knife_cookbook_doc/definitions_model.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 load_descriptions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def load_descriptions
            resource_data = IO.read(@filename)
      
            # find all attributes
            resource_data.gsub(/#{ATTRIBUTE_REGEX}/) do
      Severity: Minor
      Found in lib/knife_cookbook_doc/attributes_model.rb - About 1 hr to fix

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

            def load_descriptions
              current_section = 'main'
              @native_resource.description.each_line do |line|
                if /^ *\@action *([^ ]*) (.*)$/ =~ line
                  action_descriptions[$1] = $2.strip
        Severity: Minor
        Found in lib/knife_cookbook_doc/resource_model.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

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

            def load_descriptions
              current_section = 'main'
              description = extract_description
              description.each_line do |line|
                if /^ *\@section (.*)$/ =~ line
        Severity: Minor
        Found in lib/knife_cookbook_doc/recipe_model.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

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

            def actions
              return @actions unless @actions.nil?
        
              if default_action.is_a?(Array)
                @actions = @native_resource.actions
        Severity: Minor
        Found in lib/knife_cookbook_doc/resource_model.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

        Severity
        Category
        Status
        Source
        Language