librariesio/libraries.io

View on GitHub

Showing 111 of 149 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[: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 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 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 = 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

        Class Base has 22 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

          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 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 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 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 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 open_data_releases has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def open_data_releases
              {
                '1.0.0' => {
                  date: 'June 15, 2017',
                  filename: 'Libraries.io-open-data-1.0.0.zip',
          Severity: Minor
          Found in app/helpers/open_data_helper.rb - About 2 hrs to fix

            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 save_dependencies has a Cognitive Complexity of 15 (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|
                    next if version.dependencies.any?
            Severity: Minor
            Found in app/models/package_manager/base.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 notify_subscribers has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def notify_subscribers
                repository.projects.without_versions.each do |project|
                  subscriptions = project.subscriptions
                  subscriptions = subscriptions.include_prereleases if prerelease?
            
            
            Severity: Minor
            Found in app/models/tag.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_requirements has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def self.parse_requirements(range)
                  return unless range.present?
            
                  parts = range[1..-2].split(",")
                  requirements = []
            Severity: Minor
            Found in app/models/package_manager/nu_get.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

            Severity
            Category
            Status
            Source
            Language