mkristian/jar-dependencies

View on GitHub

Showing 40 of 40 total issues

File jar_dependencies.rb has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Jars
  unless defined? Jars::SKIP_LOCK
    MAVEN_SETTINGS = 'JARS_MAVEN_SETTINGS'
    LOCAL_MAVEN_REPO = 'JARS_LOCAL_MAVEN_REPO'
    # lock file to use
Severity: Minor
Found in lib/jar_dependencies.rb - About 2 hrs to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    configure do
      metrics = Leafy::Metrics::Registry.new
      health = Leafy::Health::Registry.new
    
      use(Leafy::Rack::Admin, metrics, health)
    examples/sinatra-app/having-gems-with-jar-dependencies/app/hellowarld.rb on lines 16..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 88.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    configure do
      metrics = Leafy::Metrics::Registry.new
      health = Leafy::Health::Registry.new
    
      use(Leafy::Rack::Admin, metrics, health)
    examples/sinatra-app/having-jarfile-and-gems-with-jar-dependencies/app/hellowarld.rb on lines 16..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 88.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        def process(scope)
          scope ||= :runtime
          File.read(@file).each_line do |line|
            next unless /:.+:/.match?(line)
    
    
    Severity: Minor
    Found in lib/jars/lock.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 require_jars_lock! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def require_jars_lock!(scope = :runtime)
          urls = jars_lock_from_class_loader
          if urls && !urls.empty?
            @jars_lock = true
            # funny error during spec where it tries to load it again
    Severity: Minor
    Found in lib/jar_dependencies.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 user_settings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def user_settings
            @_jars_maven_user_settings_ = nil unless instance_variable_defined?(:@_jars_maven_user_settings_)
            if @_jars_maven_user_settings_.nil?
              if (settings = Jars.absolute(Jars.to_prop(MAVEN_SETTINGS)))
                unless File.exist?(settings)
    Severity: Minor
    Found in lib/jars/maven_settings.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 attach_jars has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def attach_jars(spec, all_dependencies: false)
            @index ||= 0
            @done ||= []
    
            deps = GemspecArtifacts.new(spec)
    Severity: Minor
    Found in lib/jars/maven_factory.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 new has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.new(line)
            line = line.strip
            index = line.index(/\s/)
            return nil if index.nil?
    
    
    Severity: Minor
    Found in lib/jars/gemspec_artifacts.rb - About 1 hr to fix

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

            def convert(arg, low = nil, high = nil)
              if arg.include?('~>')
                val = arg.sub(/~>\s*/, '')
                last = val.include?('.') ? val.sub(/\.[0-9]*[a-z]+.*$/, '').sub(/\.[^.]+$/, '.99999') : '99999'
                ["[#{snapshot_version(val)}", "#{snapshot_version(last)}]"]
      Severity: Minor
      Found in lib/jars/gemspec_artifacts.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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          it "parse and to_s of simple GAV #{type} with one exclusion" do
            expected = "#{type} g:a, 1, [a:b]"
            a = Jars::GemspecArtifacts::Artifact.new(expected)
            a.to_s.must_equal expected
            line = "#{type} 'g:a', '1', '[a:b]'"
      Severity: Major
      Found in specs/gemspec_artifacts_spec.rb and 2 other locations - About 1 hr to fix
      specs/gemspec_artifacts_spec.rb on lines 86..98
      specs/gemspec_artifacts_spec.rb on lines 128..140

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          it "parse and to_s of simple GAV #{type} with exclusions and range" do
            expected = "#{type} g:a, (1, 2], [a:b, c:d]"
            a = Jars::GemspecArtifacts::Artifact.new(expected)
            a.to_s.must_equal expected
            line = "#{type} 'g:a', '(1,2]', ['a:b', 'c:d']'"
      Severity: Major
      Found in specs/gemspec_artifacts_spec.rb and 2 other locations - About 1 hr to fix
      specs/gemspec_artifacts_spec.rb on lines 86..98
      specs/gemspec_artifacts_spec.rb on lines 101..113

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

          it "parse and to_s of simple GAV #{type} with range" do
            expected = "#{type} g:a, [1, 2)"
            a = Jars::GemspecArtifacts::Artifact.new(expected)
            a.to_s.must_equal expected
            line = "#{type} g:a:[1, 2)"
      Severity: Major
      Found in specs/gemspec_artifacts_spec.rb and 2 other locations - About 1 hr to fix
      specs/gemspec_artifacts_spec.rb on lines 101..113
      specs/gemspec_artifacts_spec.rb on lines 128..140

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 67.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

            def global_settings
              @_jars_maven_global_settings_ = nil unless instance_variable_defined?(:@_jars_maven_global_settings_)
              if @_jars_maven_global_settings_.nil?
                if (mvn_home = ENV['M2_HOME'] || ENV['MAVEN_HOME'])
                  settings = File.join(mvn_home, 'conf/settings.xml')
      Severity: Minor
      Found in lib/jars/maven_settings.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 lock_down has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def lock_down(vendor_dir = nil, force: false, update: false, tree: nil)
            out = File.expand_path('.jars.output')
            tree_provided = tree
            tree ||= File.expand_path('.jars.tree')
            maven.property('jars.outputFile', out)
      Severity: Minor
      Found in lib/jars/lock_down.rb - About 1 hr to fix

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

            def require_jars_lock!(scope = :runtime)
              urls = jars_lock_from_class_loader
              if urls && !urls.empty?
                @jars_lock = true
                # funny error during spec where it tries to load it again
        Severity: Minor
        Found in lib/jar_dependencies.rb - About 1 hr to fix

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

                def new(*args)
                  if args.empty? || (args.size == 1 && args[0].nil?)
                    nil
                  else
                    low, high = convert(args[0])
          Severity: Minor
          Found in lib/jars/gemspec_artifacts.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 require? has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def require?
                @require = nil unless instance_variable_defined?(:@require)
                if @require.nil?
                  if (require = to_boolean(REQUIRE)).nil?
                    no_require = to_boolean(NO_REQUIRE)
          Severity: Minor
          Found in lib/jar_dependencies.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 effective_settings has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def effective_settings
                  @_jars_effective_maven_settings_ = nil unless instance_variable_defined?(:@_jars_effective_maven_settings_)
                  if @_jars_effective_maven_settings_.nil?
                    begin
                      require 'rubygems/request'
          Severity: Minor
          Found in lib/jars/maven_settings.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 convert has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def convert(arg, low = nil, high = nil)
                  if arg.include?('~>')
                    val = arg.sub(/~>\s*/, '')
                    last = val.include?('.') ? val.sub(/\.[0-9]*[a-z]+.*$/, '').sub(/\.[^.]+$/, '.99999') : '99999'
                    ["[#{snapshot_version(val)}", "#{snapshot_version(last)}]"]
          Severity: Minor
          Found in lib/jars/gemspec_artifacts.rb - About 1 hr to fix

            Similar blocks of code found in 6 locations. Consider refactoring.
            Open

              it 'should parse pom dependency' do
                dep = Jars::Installer::Dependency.new(+'   org.apache.maven:maven-repository-metadata:pom:3.1.0:compile:/usr/local/repository/org/apache/maven/maven-repository-metadata/3.1.0/maven-repository-metadata-3.1.0.pom')
                dep.type.must_equal :pom
                dep.scope.must_equal :runtime
                dep.gav.must_equal 'org.apache.maven:maven-repository-metadata:3.1.0'
            Severity: Major
            Found in specs/dependency_spec.rb and 5 other locations - About 35 mins to fix
            specs/dependency_spec.rb on lines 15..22
            specs/dependency_spec.rb on lines 25..32
            specs/dependency_spec.rb on lines 63..70
            specs/dependency_spec.rb on lines 73..80
            specs/dependency_spec.rb on lines 83..90

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 35.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language