librariesio/libraries.io

View on GitHub

Showing 155 of 155 total issues

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 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 = nil
      user_by_id = RepositoryUser.where(host_type: 'GitHub').find_by_uuid(user_hash[:id])
Severity: Minor
Found in app/models/repository_owner/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

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 = nil
      org_by_id = RepositoryOrganisation.where(host_type: 'GitHub').find_by_uuid(org_hash[:id])
Severity: Minor
Found in app/models/repository_owner/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

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 Gitlab has 22 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

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

        class Bitbucket < Base
          IGNORABLE_EXCEPTIONS = [
            BitBucket::Error::NotFound,
            BitBucket::Error::Forbidden,
            BitBucket::Error::ServiceError,
      Severity: Minor
      Found in app/models/repository_host/bitbucket.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 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

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

            def gather_maintenance_stats
              if repository.host_type != "GitHub" || repository.projects.any? { |project| project.github_name_with_owner.blank? }
                repository.repository_maintenance_stats.destroy_all
                return []
              end
        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 Base has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Base
            def initialize(repository)
              @repository = repository
            end
        
        
        Severity: Minor
        Found in app/models/repository_host/base.rb - About 2 hrs to fix

          File github.rb has 256 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

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

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

            Severity
            Category
            Status
            Source
            Language