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

Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.
Open

          notation, file_path, url, deploy_opts)
Severity: Minor
Found in lib/lock_jar/maven.rb by rubocop

This cop checks that the closing brace in a method call is either on the same line as the last method argument, or a new line.

When using the symmetrical (default) style:

If a method call's opening brace is on the same line as the first argument of the call, then the closing brace should be on the same line as the last argument of the call.

If an method call's opening brace is on the line above the first argument of the call, then the closing brace should be on the line below the last argument of the call.

When using the new_line style:

The closing brace of a multi-line method call must be on the line after the last argument of the call.

When using the same_line style:

The closing brace of a multi-line method call must be on the same line as the last argument of the call.

Example:

# symmetrical: bad
  # new_line: good
  # same_line: bad
  foo(a,
    b
  )

  # symmetrical: bad
  # new_line: bad
  # same_line: good
  foo(
    a,
    b)

  # symmetrical: good
  # new_line: bad
  # same_line: good
  foo(a,
    b)

  # symmetrical: good
  # new_line: good
  # same_line: bad
  foo(
    a,
    b
  )

Always use raise to signal exceptions.
Open

        fail "lockfile #{path} not found" if lock_data.nil?
Severity: Minor
Found in lib/lock_jar/domain/lockfile.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
Severity
Category
Status
Source
Language