mguymon/lock_jar

View on GitHub

Showing 56 of 56 total issues

Block has too many lines. [51/25]
Open

      after_define do |project|
        task compile: 'lock_jar:compile'
        task 'test:compile' => 'lock_jar:test:compile'

        task 'eclipse' => 'lock_jar:eclipse'
Severity: Minor
Found in lib/lock_jar/buildr.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method lock! has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def lock!(*opts)
        # check if Bundler has already run
        return unless ::Bundler.instance_variable_get('@setup').nil?

        dsl = nil
Severity: Minor
Found in lib/lock_jar/bundler.rb - About 2 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 load has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

      def load(lockfile_or_path, groups = ['default'], opts = {}, &blk)
        # lockfile is only loaded once
        unless lockfile_or_path.nil?
          # loaded a Lockfile instance
          if lockfile_or_path.is_a? LockJar::Domain::Lockfile
Severity: Minor
Found in lib/lock_jar/runtime/load.rb - About 2 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

Block has too many lines. [46/25]
Open

        namespace 'lock_jar' do
          desc 'Lock dependencies to JarFile'
          task('lock') do
            dsl = project.lockjar_dsl
            if dsl
Severity: Minor
Found in lib/lock_jar/buildr.rb by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Method list has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def list(lockfile_or_path, groups = ['default'], opts = {}, &blk)
        dependencies = []
        maps = []
        with_locals = { with_locals: true }.merge(opts).delete(:with_locals)

Severity: Minor
Found in lib/lock_jar/runtime/list.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 extract_args has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def extract_args(type, args, &blk)
      lockfile_or_path = nil
      opts = {}
      groups = ['default']
      args.each do |arg|
Severity: Minor
Found in lib/lock_jar.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 list has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def list(lockfile_or_path, groups = ['default'], opts = {}, &blk)
        dependencies = []
        maps = []
        with_locals = { with_locals: true }.merge(opts).delete(:with_locals)

Severity: Minor
Found in lib/lock_jar/runtime/list.rb - About 1 hr to fix

Method apply_artifacts! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def apply_artifacts!(artifacts)
        # Build the dependencies_graph hash in the resolver
        resolver(opts).resolve(
          artifacts.select(&:resolvable?).map(&:to_dep), opts[:download] == true
        )
Severity: Minor
Found in lib/lock_jar/runtime/lock.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 assign_groups has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def assign_groups(artifact, groups = nil)
        if groups
          groups = Array(groups)

          # include present group if within a group block
Severity: Minor
Found in lib/lock_jar/domain/dsl.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 lockfile_dependencies has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def lockfile_dependencies(lockfile, groups, with_locals = true)
      dependencies = []

      groups.each do |group|
        next unless lockfile.groups[group.to_s]
Severity: Minor
Found in lib/lock_jar/runtime.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 to_hash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def to_hash
        lock_data = { 'version' => @version }

        lock_data['local_repository'] = local_repository unless local_repository.nil?

Severity: Minor
Found in lib/lock_jar/domain/lockfile.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 artifact_groups has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

      def artifact_groups(restrict = nil)
        artifacts = Hash.new { |hash, key| hash[key] = [] }

        from_dsl.artifacts.each do |group, group_artifacts|
          next if restrict && !restrict.include?(group)
Severity: Minor
Found in lib/lock_jar/domain/dsl_merger.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 fs_or_classpath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def self.fs_or_classpath(path)
        if File.exist? path
          YAML.load_file(path)

        # Lookup of Jarfile.lock in the classpath
Severity: Minor
Found in lib/lock_jar/domain/lockfile.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 deploy_artifact has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def deploy_artifact(notation, file_path, url, deploy_opts = {}, lockjar_opts = {})
Severity: Minor
Found in lib/lock_jar/maven.rb - About 35 mins to fix

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

      def create_dsl!(jarfile_or_dsl, &blk)
        if jarfile_or_dsl
          @jarfile = if jarfile_or_dsl.is_a? LockJar::Domain::Dsl
                       jarfile_or_dsl
                     else
Severity: Minor
Found in lib/lock_jar/runtime/lock.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 resolver has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def resolver(opts = {})
      # XXX: Caches the resolver by the options. Passing in nil opts will replay
      #      from the cache. This need to change.
      if !opts.nil?
        opts[:local_repo] = File.expand_path(opts[:local_repo]) if opts[:local_repo]
Severity: Minor
Found in lib/lock_jar/runtime.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 write_pom has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def write_pom(notation, file_path, opts = {})
        opts = { include_resolved: true }.merge(opts)

        maven = Naether::Maven.create_from_notataion(notation)

Severity: Minor
Found in lib/lock_jar/maven.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 add_artifact! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def add_artifact!(group, artifact_data, artifact)
        if artifact.is_a? LockJar::Domain::Jar
          group['dependencies'] << artifact.notation
          g = resolver(opts).dependencies_graph[artifact.notation]
          artifact_data['transitive'] = g.to_hash if g
Severity: Minor
Found in lib/lock_jar/runtime/lock.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

Always use raise to signal exceptions.
Open

      fail "Jarfile not found: #{jarfile}" unless File.exist? jarfile
Severity: Minor
Found in lib/lock_jar.rb by rubocop

This cop checks for uses of fail and raise.

Example: EnforcedStyle: only_raise (default)

# The `only_raise` style enforces the sole use of `raise`.
# bad
begin
  fail
rescue Exception
  # handle it
end

def watch_out
  fail
rescue Exception
  # handle it
end

Kernel.fail

# good
begin
  raise
rescue Exception
  # handle it
end

def watch_out
  raise
rescue Exception
  # handle it
end

Kernel.raise

Example: EnforcedStyle: only_fail

# The `only_fail` style enforces the sole use of `fail`.
# bad
begin
  raise
rescue Exception
  # handle it
end

def watch_out
  raise
rescue Exception
  # handle it
end

Kernel.raise

# good
begin
  fail
rescue Exception
  # handle it
end

def watch_out
  fail
rescue Exception
  # handle it
end

Kernel.fail

Example: EnforcedStyle: semantic

# The `semantic` style enforces the use of `fail` to signal an
# exception, then will use `raise` to trigger an offense after
# it has been rescued.
# bad
begin
  raise
rescue Exception
  # handle it
end

def watch_out
  # Error thrown
rescue Exception
  fail
end

Kernel.fail
Kernel.raise

# good
begin
  fail
rescue Exception
  # handle it
end

def watch_out
  fail
rescue Exception
  raise 'Preferably with descriptive message'
end

explicit_receiver.fail
explicit_receiver.raise

Use (self.<=>(other)).zero? instead of self.<=>(other) == 0.
Open

        self.<=>(other) == 0
Severity: Minor
Found in lib/lock_jar/domain/artifact.rb by rubocop

This cop checks for usage of comparison operators (==, >, <) to test numbers as zero, positive, or negative. These can be replaced by their respective predicate methods. The cop can also be configured to do the reverse.

The cop disregards #nonzero? as it its value is truthy or falsey, but not true and false, and thus not always interchangeable with != 0.

The cop ignores comparisons to global variables, since they are often populated with objects which can be compared with integers, but are not themselves Interger polymorphic.

Example: EnforcedStyle: predicate (default)

# bad

foo == 0
0 > foo
bar.baz > 0

# good

foo.zero?
foo.negative?
bar.baz.positive?

Example: EnforcedStyle: comparison

# bad

foo.zero?
foo.negative?
bar.baz.positive?

# good

foo == 0
0 > foo
bar.baz > 0
Severity
Category
Status
Source
Language