librariesio/libraries.io

View on GitHub

Showing 108 of 148 total issues

Class Project has 69 methods (exceeds 20 allowed). Consider refactoring.
Open

class Project < ApplicationRecord
  include ProjectSearch
  include SourceRank
  include Status
  include Releases
Severity: Major
Found in app/models/project.rb - About 1 day to fix

    Class ProjectScoreCalculator has 56 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ProjectScoreCalculator
      def initialize(project, max_dependent_projects: nil, max_dependent_repositories: nil, max_stars: nil, max_forks: nil, max_watchers: nil)
        @project = project
        @max_dependent_projects = max_dependent_projects
        @max_dependent_repositories = max_dependent_repositories
    Severity: Major
    Found in app/models/project_score_calculator.rb - About 1 day to fix

      File project.rb has 439 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      class Project < ApplicationRecord
        include ProjectSearch
        include SourceRank
        include Status
        include Releases
      Severity: Minor
      Found in app/models/project.rb - About 6 hrs to fix

        Method create_from_hash has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.create_from_hash(repo_hash)
            return unless repo_hash
            repo_hash = repo_hash.to_hash.with_indifferent_access
            ActiveRecord::Base.transaction do
              g = Repository.where(host_type: (repo_hash[:host_type] || 'GitHub')).find_by(uuid: repo_hash[:id])
        Severity: Minor
        Found in app/models/repository.rb - About 5 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 36 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Base
            COLOR = '#fff'
            BIBLIOTHECARY_SUPPORT = false
            BIBLIOTHECARY_PLANNED = false
            SECURITY_PLANNED = false
        Severity: Minor
        Found in app/models/package_manager/base.rb - About 4 hrs to fix

          Class Repository has 36 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Repository < ApplicationRecord
            include RepoSearch
            include Status
            include RepoManifests
            include RepositorySourceRank
          Severity: Minor
          Found in app/models/repository.rb - About 4 hrs to fix

            Class ApplicationController has 35 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class ApplicationController < ActionController::Base
              include Rails::Pagination
              # Prevent CSRF attacks by raising an exception.
              # For APIs, you may want to use :null_session instead.
              protect_from_forgery with: :exception
            Severity: Minor
            Found in app/controllers/application_controller.rb - About 4 hrs to fix

              Class URLParser has 31 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class URLParser
                def self.parse(url)
                  new(url).parse
                end
              
              
              Severity: Minor
              Found in app/services/url_parser.rb - About 3 hrs to fix

                File project_score_calculator.rb has 315 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class ProjectScoreCalculator
                  def initialize(project, max_dependent_projects: nil, max_dependent_repositories: nil, max_stars: nil, max_forks: nil, max_watchers: nil)
                    @project = project
                    @max_dependent_projects = max_dependent_projects
                    @max_dependent_repositories = max_dependent_repositories
                Severity: Minor
                Found in app/models/project_score_calculator.rb - About 3 hrs to fix

                  Class ProjectsController has 29 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class ProjectsController < ApplicationController
                    before_action :ensure_logged_in, only: [:your_dependent_repos, :mute, :unmute,
                                                            :unsubscribe, :sync]
                    before_action :find_project, only: [:show, :sourcerank, :about, :dependents,
                                                        :dependent_repos, :your_dependent_repos,
                  Severity: Minor
                  Found in app/controllers/projects_controller.rb - About 3 hrs to fix

                    Method find_version has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def find_version
                        @version_count = @project.versions.size
                        @repository = @project.repository
                        if @version_count.zero?
                          @versions = []
                    Severity: Minor
                    Found in app/controllers/application_controller.rb - About 3 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 79 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

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

                      Method show has a Cognitive Complexity of 22 (exceeds 5 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 3 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_repo_permissions has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update_repo_permissions
                          return unless token
                          self.update_column(:currently_syncing, true)
                          download_orgs
                          r = github_client.repos
                      Severity: Minor
                      Found in app/models/concerns/github_identity.rb - About 3 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 26 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                        class Base
                          attr_reader :owner
                      
                          def initialize(owner)
                            @owner = owner
                      Severity: Minor
                      Found in app/models/repository_owner/base.rb - About 3 hrs to fix

                        File repository.rb has 278 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        class Repository < ApplicationRecord
                          include RepoSearch
                          include Status
                          include RepoManifests
                          include RepositorySourceRank
                        Severity: Minor
                        Found in app/models/repository.rb - About 2 hrs to fix

                          Class Version has 23 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class Version < ApplicationRecord
                            include Releaseable
                          
                            validates_presence_of :project_id, :number
                            validates_uniqueness_of :number, scope: :project_id
                          Severity: Minor
                          Found in app/models/version.rb - About 2 hrs to fix

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

                            Severity
                            Category
                            Status
                            Source
                            Language