librariesio/libraries.io

View on GitHub

Showing 148 of 148 total issues

Method parse_requirements has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.parse_requirements(range)
      return unless range.present?
      parts = range[1..-2].split(',')
      requirements = []
      low_bound = range[0]
Severity: Minor
Found in app/models/package_manager/nu_get.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 create_user has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_user(user_hash)
      return if user_hash.nil?
      user_hash = user_hash.to_hash.with_indifferent_access
      user_hash = {
        id: user_hash[:id],
Severity: Minor
Found in app/models/repository_owner/gitlab.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 create_org has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_org(org_hash)
      return if org_hash.nil?
      org_hash = org_hash.to_hash.with_indifferent_access
      org_hash = {
        id: org_hash[:id],
Severity: Minor
Found in app/models/repository_owner/gitlab.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 create_org has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.create_org(org_hash)
      return if org_hash.nil?
      org_hash = org_hash.to_hash.with_indifferent_access
      org_hash = {
        id: org_hash[:uuid],
Severity: Minor
Found in app/models/repository_owner/bitbucket.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 search has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.search(query, options = {})
      facet_limit = options.fetch(:facet_limit, 36)
      options[:filters] ||= []
      search_definition = {
        query: {
Severity: Major
Found in app/models/concerns/project_search.rb - About 2 hrs to fix

    Class Github has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Github < Base
        IGNORABLE_EXCEPTIONS = [
          Octokit::Unauthorized,
          Octokit::InvalidRepository,
          Octokit::RepositoryUnavailable,
    Severity: Minor
    Found in app/models/repository_host/github.rb - About 2 hrs to fix

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

          def download_readme(token = nil)
            files = api_client(token).repos.sources.list(repository.owner_name, repository.project_name, URI.escape(repository.default_branch || 'master'), '/')
            paths =  files.files.map(&:path)
            readme_path = paths.select{|path| path.match(/^readme/i) }.sort{|path| Readme.supported_format?(path) ? 0 : 1 }.first
            return if readme_path.nil?
      Severity: Minor
      Found in app/models/repository_host/bitbucket.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 gather_stats has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.gather_stats(repository)
              # only support Github repos for now
              # check to make sure the Project URLs are also pointing to a Github repository
              unless stats_enabled?(repository)
                  # if this repository should not have stats, delete any existing ones and return immediately
      Severity: Minor
      Found in app/models/gather_repository_maintenance_stats.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 download_contributions has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def download_contributions(token = nil)
            return if repository.fork?
            gh_contributions = api_client(token).contributors(repository.full_name)
            return if gh_contributions.empty?
            existing_contributions = repository.contributions.includes(:repository_user).to_a
      Severity: Minor
      Found in app/models/repository_host/github.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

      Class Gitlab has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Gitlab < Base
          IGNORABLE_EXCEPTIONS = [::Gitlab::Error::NotFound, ::Gitlab::Error::Forbidden, ::Gitlab::Error::InternalServerError, ::Gitlab::Error::Parsing]
      
          def self.api_missing_error_class
            ::Gitlab::Error::NotFound
      Severity: Minor
      Found in app/models/repository_host/gitlab.rb - About 2 hrs to fix

        Method query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

                    def query(params: {})
                        validate_params(params)
        
                        end_date = params[:end_date]
                        params = params.slice!(:end_date)
        Severity: Minor
        Found in app/models/maintenance_stats/queries/releases_query.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 search has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.search(query, options = {})
              facet_limit = options.fetch(:facet_limit, 35)
              options[:filters] ||= []
              options[:must_not] ||= []
              search_definition = {
        Severity: Minor
        Found in app/models/concerns/repo_search.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 check_status has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.check_status(host_type, repo_full_name, removed = false)
            domain = RepositoryHost::Base.domain(host_type)
            response = Typhoeus.head("#{domain}/#{repo_full_name}")
        
            if response.response_code == 404
        Severity: Minor
        Found in app/models/repository.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 download_owner has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def download_owner
              return if repository.owner && repository.repository_user_id && repository.owner.login == repository.owner_name
              namespace = api_client.project(repository.full_name).try(:namespace)
              return unless namespace
              if namespace.kind == 'group'
        Severity: Minor
        Found in app/models/repository_host/gitlab.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 save_dependencies has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.save_dependencies(mapped_project)
              name = mapped_project[:name]
              proj = Project.find_by(name: name, platform: self.name.demodulize)
              proj.versions.includes(:dependencies).each do |version|
                deps = dependencies(name, version.number, mapped_project) rescue []
        Severity: Minor
        Found in app/models/package_manager/base.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 update_from_host has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_from_host(token = nil)
              begin
                r = self.class.fetch_repo(repository.id_or_name)
                return unless r.present?
                repository.uuid = r[:id] unless repository.uuid.to_s == r[:id].to_s
        Severity: Minor
        Found in app/models/repository_host/base.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 download_readme has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def download_readme(token = nil)
              files = api_client(token).tree(repository.full_name)
              paths =  files.map(&:path)
              readme_path = paths.select{|path| path.match(/^readme/i) }.sort{|path| Readme.supported_format?(path) ? 0 : 1 }.first
              return if readme_path.nil?
        Severity: Minor
        Found in app/models/repository_host/gitlab.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_dependencies_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def load_dependencies_for(version, dependency, kind, index)
            if version
              @license_names << version.project.try(:normalized_licenses)
              kind = index.zero? ? kind : 'runtime'
              dependencies = version.dependencies.kind(kind).includes(project: :versions).limit(100).order(:project_name)
        Severity: Minor
        Found in app/models/tree_resolver.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 load_dependencies_for has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def load_dependencies_for(version, dependency, kind, index)
            if version
              @license_names << version.project.try(:normalize_licenses)
              kind = index.zero? ? kind : 'runtime'
              dependencies = version.dependencies.kind(kind).includes(project: :versions).limit(100).order(:project_name)
        Severity: Minor
        Found in app/models/repository_tree_resolver.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 gather_stats has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.gather_stats(repository)
                # only support Github repos for now
                # check to make sure the Project URLs are also pointing to a Github repository
                unless stats_enabled?(repository)
                    # if this repository should not have stats, delete any existing ones and return immediately
        Severity: Minor
        Found in app/models/gather_repository_maintenance_stats.rb - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language