librariesio/libraries.io

View on GitHub

Showing 155 of 155 total issues

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_maintenance_stats has 45 lines of code (exceeds 25 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 1 hr to fix

    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 open_data_releases has 42 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 1 hr to fix

      Method download_owner has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def download_owner
            return if repository.owner && repository.repository_user_id && repository.owner.login == repository.owner_name
            o = RepositoryOwner::Bitbucket.fetch_user(repository.owner_name)
            if o.type == "team"
              org = RepositoryOrganisation.create_from_host('Bitbucket', o)
      Severity: Minor
      Found in app/models/repository_host/bitbucket.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 search has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.search(query, options = {})
            facet_limit = options.fetch(:facet_limit, 36)
            options[:filters] ||= []
            search_definition = {
              query: {
      Severity: Minor
      Found in app/models/concerns/project_search.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

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

            if user_by_id # its fine
              if user_by_id.login.try(:downcase) == user_hash[:login].downcase && user_by_id.user_type == user_hash[:type]
                user = user_by_id
              else
                if user_by_login && !user_by_login.download_user_from_host
      Severity: Major
      Found in app/models/repository_owner/github.rb and 2 other locations - About 1 hr to fix
      app/models/repository_owner/bitbucket.rb on lines 86..103
      app/models/repository_owner/gitlab.rb on lines 100..117

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

      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 normalize_licenses has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

        def normalize_licenses
          if licenses.blank?
            normalized = []
          elsif licenses.length > 150
            normalized = ['Other']
      Severity: Minor
      Found in app/models/project.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

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

            if user_by_id # its fine
              if user_by_id.login.try(:downcase) == user_hash[:login].downcase && user_by_id.user_type == user_hash[:type]
                user = user_by_id
              else
                if user_by_login && !user_by_login.download_user_from_host
      Severity: Major
      Found in app/models/repository_owner/bitbucket.rb and 2 other locations - About 1 hr to fix
      app/models/repository_owner/github.rb on lines 103..120
      app/models/repository_owner/gitlab.rb on lines 100..117

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

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

            if user_by_id # its fine
              if user_by_id.login.try(:downcase) == user_hash[:login].downcase && user_by_id.user_type == user_hash[:type]
                user = user_by_id
              else
                if user_by_login && !user_by_login.download_user_from_host
      Severity: Major
      Found in app/models/repository_owner/gitlab.rb and 2 other locations - About 1 hr to fix
      app/models/repository_owner/bitbucket.rb on lines 86..103
      app/models/repository_owner/github.rb on lines 103..120

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

      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 save has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.save(project)
            return unless project.present?
            mapped_project = mapping(project)
            mapped_project = mapped_project.delete_if { |_key, value| value.blank? } if mapped_project.present?
            return false unless mapped_project.present?
      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 download_owner has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def download_owner
            return if repository.owner && repository.repository_user_id && repository.owner.login == repository.owner_name
            o = api_client.user(repository.owner_name)
            if o.type == "Organization"
              go = RepositoryOrganisation.create_from_host('GitHub', o)
      Severity: Minor
      Found in app/models/repository_host/github.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 create_user has 38 lines of code (exceeds 25 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 1 hr to fix

        Method create_user has 37 lines of code (exceeds 25 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 1 hr to fix

          Method create_org has 37 lines of code (exceeds 25 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 1 hr to fix

            Method create_org has 36 lines of code (exceeds 25 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 1 hr to fix

              Method show has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def show
                  @issues = @project.repository.try(:issues)
                  @tags = @project.repository.try(:tags)
                  @events = []
                  @project.versions.each do |version|
              Severity: Minor
              Found in app/controllers/timeline_controller.rb - About 1 hr to fix

                Method mapping_from_pom_xml has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.mapping_from_pom_xml(version_xml, depth = 0)
                      if version_xml.respond_to?('project')
                        xml = version_xml.project
                      else
                        xml = version_xml
                Severity: Minor
                Found in app/models/package_manager/maven.rb - About 1 hr to fix

                  Method breakdown has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def breakdown
                      {
                        overall_score: overall_score,
                        popularity: {
                          score: popularity_score,
                  Severity: Minor
                  Found in app/models/project_score_calculator.rb - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language