RiotGames/berkshelf

View on GitHub

Showing 52 of 54 total issues

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

    def initialize(berksfile, source, **options)
      @options = { timeout: api_timeout, open_timeout: [(api_timeout / 10), 3].max, ssl: {} }
      @options.update(options)
      case source
      when String
Severity: Minor
Found in lib/berkshelf/source.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 13 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(**opts)
      opts = opts.dup
      opts[:ssl] ||= {}
      chef_opts = {}
      chef_opts[:rest_timeout]         = opts[:timeout] if opts[:timeout] # opts[:open_timeout] is ignored on purpose
Severity: Minor
Found in lib/berkshelf/ridley_compat.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 trusted? has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def trusted?
      Berkshelf.log.info "Checking if lockfile is trusted"

      checked = {}

Severity: Minor
Found in lib/berkshelf/lockfile.rb - About 1 hr to fix

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

        def upload(cookbooks)
          Berkshelf.log.info "Starting upload"
    
          Berkshelf.ridley_connection(options) do |connection|
            # this is a hack to work around a bug in chef 13.0-13.2 protocol negotiation on POST requests, its only
    Severity: Minor
    Found in lib/berkshelf/uploader.rb - About 1 hr to fix

      Method apply has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def apply(name, options = {})
            locks = graph.locks.inject({}) do |hash, (dep_name, dependency)|
              hash[dep_name] = "= #{dependency.locked_version}"
              hash
            end
      Severity: Minor
      Found in lib/berkshelf/lockfile.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 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def initialize(berksfile, source, **options)
            @options = { timeout: api_timeout, open_timeout: [(api_timeout / 10), 3].max, ssl: {} }
            @options.update(options)
            case source
            when String
      Severity: Minor
      Found in lib/berkshelf/source.rb - About 1 hr to fix

        Method cookbooks has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def cookbooks(filter = nil)
              skipped_cookbooks = []
              cookbooks = storage_path.children.collect do |path|
                begin
                  Semverse::Version.split(File.basename(path).slice(CachedCookbook::DIRNAME_REGEXP, 2))
        Severity: Minor
        Found in lib/berkshelf/cookbook_store.rb - About 1 hr to fix

          Method ridley_connection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def ridley_connection(options = {}, &block)
                ssl_options              = {}
                ssl_options[:verify]     = if options[:ssl_verify].nil?
                                             Berkshelf.config.ssl.verify
                                           else
          Severity: Minor
          Found in lib/berkshelf.rb - About 1 hr to fix

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

                def satisfies_transitive?(graph_item, checked, level = 0)
                  indent = " " * (level + 2)
            
                  Berkshelf.log.debug "#{indent}Checking transitive dependencies for #{graph_item}"
            
            
            Severity: Minor
            Found in lib/berkshelf/lockfile.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 universe has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def universe
                  Dir.entries(cookbooks_path).sort.each_with_object([]) do |entry, cookbooks|
                    next if entry[0] == "." # Skip hidden folders.
            
                    entry_path = "#{cookbooks_path}/#{entry}"
            Severity: Minor
            Found in lib/berkshelf/chef_repo_universe.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 sync has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def sync(source, destination, options = {})
                  unless File.directory?(source)
                    raise ArgumentError, "`source' must be a directory, but was a " \
                      "`#{File.ftype(source)}'! If you just want to sync a file, use " \
                      "the `copy' method instead."
            Severity: Minor
            Found in lib/berkshelf/file_syncer.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 dispatch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                  def dispatch(meth, given_args, given_opts, config)
                    if given_args.length > 1 && !(given_args & Thor::HELP_MAPPINGS).empty?
                      command = given_args.first
            
                      if subcommands.include?(command)
            Severity: Minor
            Found in lib/berkshelf/cli.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 cookbooks has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def cookbooks(filter = nil)
                  skipped_cookbooks = []
                  cookbooks = storage_path.children.collect do |path|
                    begin
                      Semverse::Version.split(File.basename(path).slice(CachedCookbook::DIRNAME_REGEXP, 2))
            Severity: Minor
            Found in lib/berkshelf/cookbook_store.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 add_dependency has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def add_dependency(name, constraint = nil, options = {})
                  if @dependencies[name]
                    # Only raise an exception if the dependency is a true duplicate
                    groups = (options[:group].nil? || options[:group].empty?) ? [:default] : options[:group]
                    unless (@dependencies[name].groups & groups).empty?
            Severity: Minor
            Found in lib/berkshelf/berksfile.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 uninstall_cookbook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def uninstall_cookbook(cookbook, force = false)
                    unless options[:force] || (contingent = contingencies(cookbook)).empty?
                      contingent = contingent.map { |c| "#{c.cookbook_name} (#{c.version})" }.join(", ")
                      confirm = Berkshelf.ui.ask("[#{contingent}] depend on #{cookbook.cookbook_name}.\n\nAre you sure you want to continue? (y/N)")
            
            
            Severity: Minor
            Found in lib/berkshelf/commands/shelf.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 add has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def add(severity, message = nil, progname = nil, &block)
                  severity ||= Logger::UNKNOWN
                  if @logdev.nil? || severity < (@level)
                    return true
                  end
            Severity: Minor
            Found in lib/berkshelf/logger.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
            Severity: Minor
            Found in lib/berkshelf/cli.rb - About 35 mins to fix

              Method outdated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def outdated(*names, include_non_satisfying: false)
                    validate_lockfile_present!
                    validate_lockfile_trusted!
                    validate_dependencies_installed!
                    validate_cookbook_names!(names)
              Severity: Minor
              Found in lib/berkshelf/berksfile.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 outdated has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def outdated(hash)
                    if hash.empty?
                      Berkshelf.ui.info("All cookbooks up to date!")
                    else
                      Berkshelf.ui.info("The following cookbooks have newer versions:")
              Severity: Minor
              Found in lib/berkshelf/formatters/human.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 validate_cached! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def validate_cached!(path)
                    unless File.cookbook?(path)
                      raise NotACookbook.new(path)
                    end
              
              
              Severity: Minor
              Found in lib/berkshelf/locations/base.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