mineworks/license_auto

View on GitHub

Showing 31 of 31 total issues

Method parser_pom has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    def parser_pom(pom_url, pom_str)
      LicenseAuto.logger.debug("pom_str:\n#{pom_str[0..70]}")
      doc = Nokogiri::XML(pom_str).remove_namespaces!

      # Source Code Manager
Severity: Minor
Found in lib/license_auto/website/maven_central_repository.rb - About 4 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 parser_pom has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parser_pom(pom_url, pom_str)
      LicenseAuto.logger.debug("pom_str:\n#{pom_str[0..70]}")
      doc = Nokogiri::XML(pom_str).remove_namespaces!

      # Source Code Manager
Severity: Major
Found in lib/license_auto/website/maven_central_repository.rb - About 3 hrs to fix

    Method get_license_info has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_license_info()
        possible_ref = @ref || match_versioned_ref
        LicenseAuto.logger.debug("possible_ref: #{possible_ref}")
        # If possible_ref is nil, the Github API server will return the default branch contents
        contents = @server.repos.contents.get(path: '/', ref: possible_ref)
    Severity: Minor
    Found in lib/license_auto/website/github_com.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 get_license_info has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_license_info()
        possible_ref = @ref || match_versioned_ref
        LicenseAuto.logger.debug("possible_ref: #{possible_ref}")
        # If possible_ref is nil, the Github API server will return the default branch contents
        contents = @server.repos.contents.get(path: '/', ref: possible_ref)
    Severity: Major
    Found in lib/license_auto/website/github_com.rb - About 2 hrs to fix

      Method get_license_info has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def get_license_info()
            if @package.version.nil?
              begin
                @package.version = chose_latest_available_version('*')
              rescue Exception => e
      Severity: Major
      Found in lib/license_auto/website/npm_registry.rb - About 2 hrs to fix

        Method parse_dependencies has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_dependencies
              # gemfiles = dependency_file_path_names(pattern=gemfile_pattern)
              # definition = ::Bundler::Definition.build(gemfiles.first, nil, nil)
        
              # definition.dependencies.each {|dep|
        Severity: Minor
        Found in lib/license_auto/package_manager/bundler.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 parse_dependencies has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def parse_dependencies
        
              package_json_files = dependency_file_path_names
              if package_json_files.empty?
                LicenseAuto.logger.info("#{LANGUAGE}: #{dependency_file_pattern} file not exist")
        Severity: Minor
        Found in lib/license_auto/package_manager/npm.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 parse_dependencies has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parse_dependencies
        
              package_json_files = dependency_file_path_names
              if package_json_files.empty?
                LicenseAuto.logger.info("#{LANGUAGE}: #{dependency_file_pattern} file not exist")
        Severity: Minor
        Found in lib/license_auto/package_manager/npm.rb - About 1 hr to fix

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

              def chose_package_server()
                begin
                  @server =
                      if self.language == 'Golang' and self.server
                        matcher = Matcher::SourceURL.new(self.server)
          Severity: Minor
          Found in lib/license_auto/package.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 get_license_info has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_license_info()
                if @package.version.nil?
                  begin
                    @package.version = chose_latest_available_version('*')
                  rescue Exception => e
          Severity: Minor
          Found in lib/license_auto/website/npm_registry.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 parse_dependencies has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def parse_dependencies
                # gemfiles = dependency_file_path_names(pattern=gemfile_pattern)
                # definition = ::Bundler::Definition.build(gemfiles.first, nil, nil)
          
                # definition.dependencies.each {|dep|
          Severity: Minor
          Found in lib/license_auto/package_manager/bundler.rb - About 1 hr to fix

            Method get_license_info has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def get_license_info()
                if @package.version.nil?
                  begin
                    @package.version = get_latest_version['number']
                  rescue Exception => e
            Severity: Minor
            Found in lib/license_auto/website/ruby_gems_org.rb - About 1 hr to fix

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

                  def get_license_info()
                    license_info = LicenseAuto::LicenseInfoWrapper.new
                    query_set = select
              
                    if query_set.nil?
              Severity: Minor
              Found in lib/license_auto/website/maven_central_repository.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 chose_package_server has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def chose_package_server()
                    begin
                      @server =
                          if self.language == 'Golang' and self.server
                            matcher = Matcher::SourceURL.new(self.server)
              Severity: Minor
              Found in lib/license_auto/package.rb - About 1 hr to fix

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

                    def list_dependencies
                      if resolve_dependencies
                        deps = Set.new
                        Dir.chdir(@path) do
                          cmd = 'mvn dependency:list -T 4 -DincludeScope=runtime'
                Severity: Minor
                Found in lib/license_auto/package_manager/maven.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 get_license_info has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                  def get_license_info()
                    if @package.version.nil?
                      begin
                        @package.version = get_latest_version['number']
                      rescue Exception => e
                Severity: Minor
                Found in lib/license_auto/website/ruby_gems_org.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_dependencies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    def list_dependencies(project_name=nil)
                      Dir.chdir(@path) do
                        deps = Set.new
                        cmd = if project_name
                                "gradle -q #{project_name}:dependencies --configuration runtime"
                Severity: Minor
                Found in lib/license_auto/package_manager/gradle.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 parse_dependencies has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def parse_dependencies
                      contents = list_contents
                      if contents.nil?
                        LicenseAuto.logger.info("Golang dependencies not exist")
                        return []
                Severity: Minor
                Found in lib/license_auto/package_manager/golang.rb - About 1 hr to fix

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

                      def self.check_cli
                        bash_cmd = "go version"
                        # LicenseAuto.logger.debug(bash_cmd)
                        stdout_str, stderr_str, _status = Open3.capture3(bash_cmd)
                        golang_version = /1\.[456]/
                  Severity: Major
                  Found in lib/license_auto/package_manager/golang.rb and 1 other location - About 1 hr to fix
                  lib/license_auto/package_manager/bower.rb on lines 73..88

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

                  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 2 locations. Consider refactoring.
                  Open

                      def self.check_cli
                        bash_cmd = "bower -version"
                        # LicenseAuto.logger.debug(bash_cmd)
                        stdout_str, stderr_str, _status = Open3.capture3(bash_cmd)
                        bower_version = /1\./
                  Severity: Major
                  Found in lib/license_auto/package_manager/bower.rb and 1 other location - About 1 hr to fix
                  lib/license_auto/package_manager/golang.rb on lines 169..184

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

                  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