berkshelf/ridley

View on GitHub
lib/ridley/chef/cookbook/metadata.rb

Summary

Maintainability
D
2 days
Test Coverage

File metadata.rb has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Ridley::Chef
  class Cookbook
    # Borrowed and modified from: {https://raw.github.com/opscode/chef/11.4.0/lib/chef/cookbook/metadata.rb}
    #
    # Copyright:: Copyright 2008-2010 Opscode, Inc.
Severity: Minor
Found in lib/ridley/chef/cookbook/metadata.rb - About 5 hrs to fix

    Class Metadata has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

        class Metadata
          class << self
            def from_hash(hash)
              new.from_hash(hash)
            end
    Severity: Minor
    Found in lib/ridley/chef/cookbook/metadata.rb - About 5 hrs to fix

      Method from_hash has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

            def from_hash(o)
              @name             = o[NAME] if o.has_key?(NAME)
              @description      = o[DESCRIPTION] if o.has_key?(DESCRIPTION)
              @long_description = o[LONG_DESCRIPTION] if o.has_key?(LONG_DESCRIPTION)
              @maintainer       = o[MAINTAINER] if o.has_key?(MAINTAINER)
      Severity: Minor
      Found in lib/ridley/chef/cookbook/metadata.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

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

            def initialize(cookbook = nil, maintainer = 'YOUR_COMPANY_NAME', maintainer_email = 'YOUR_EMAIL', license = 'none')
              @cookbook = cookbook
              @name = cookbook ? cookbook.name : ""
              @long_description = ""
              self.maintainer(maintainer)
      Severity: Minor
      Found in lib/ridley/chef/cookbook/metadata.rb - About 1 hr to fix

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

                def validate_choice_default_rule(options)
                  return if !options[:choice].is_a?(Array) || options[:choice].empty?
        
                  if options[:default].is_a?(String) && options[:default] != ""
                    raise ArgumentError, "Default must be one of your choice values!" if options[:choice].index(options[:default]) == nil
        Severity: Minor
        Found in lib/ridley/chef/cookbook/metadata.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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(cookbook = nil, maintainer = 'YOUR_COMPANY_NAME', maintainer_email = 'YOUR_EMAIL', license = 'none')
                @cookbook = cookbook
                @name = cookbook ? cookbook.name : ""
                @long_description = ""
                self.maintainer(maintainer)
        Severity: Minor
        Found in lib/ridley/chef/cookbook/metadata.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

        There are no issues that match your filters.

        Category
        Status