rubygems/rubygems.org

View on GitHub

Showing 27 of 31 total issues

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

class Version < ApplicationRecord
  MAX_TEXT_FIELD_LENGTH = 64_000

  belongs_to :rubygem, touch: true
  has_many :dependencies, -> { order("rubygems.name ASC").includes(:rubygem) }, dependent: :destroy, inverse_of: "version"
Severity: Major
Found in app/models/version.rb - About 1 day to fix

    Class Rubygem has 57 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Rubygem < ApplicationRecord
      include Patterns
      include RubygemSearchable
    
      has_many :ownerships, -> { confirmed }, dependent: :destroy, inverse_of: :rubygem
    Severity: Major
    Found in app/models/rubygem.rb - About 1 day to fix

      Class User has 42 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class User < ApplicationRecord
        include Clearance::User
        include Gravtastic
        is_gravtastic default: "retro"
      
      
      Severity: Minor
      Found in app/models/user.rb - About 5 hrs to fix

        Method error_messages_for has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

          def error_messages_for(*params)
            options = params.extract_options!.symbolize_keys
        
            objects = Array.wrap(options.delete(:object) || params).map do |object|
              object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
        Severity: Minor
        Found in app/helpers/dynamic_errors_helper.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

        File version.rb has 328 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "digest/sha2"
        
        class Version < ApplicationRecord
          MAX_TEXT_FIELD_LENGTH = 64_000
        
        
        Severity: Minor
        Found in app/models/version.rb - About 3 hrs to fix

          File rubygem.rb has 299 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          class Rubygem < ApplicationRecord
            include Patterns
            include RubygemSearchable
          
            has_many :ownerships, -> { confirmed }, dependent: :destroy, inverse_of: :rubygem
          Severity: Minor
          Found in app/models/rubygem.rb - About 3 hrs to fix

            Method update has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              def update
                to_enable_push = []
                to_disable_push = []
                to_enable_owner = []
                to_disable_owner = []
            Severity: Minor
            Found in app/controllers/notifiers_controller.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 error_messages_for has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def error_messages_for(*params)
                options = params.extract_options!.symbolize_keys
            
                objects = Array.wrap(options.delete(:object) || params).map do |object|
                  object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
            Severity: Minor
            Found in app/helpers/dynamic_errors_helper.rb - About 1 hr to fix

              Method search_definition has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def search_definition(for_api: false) # rubocop:disable Metrics/MethodLength
                  query_str = @query
                  source_array = for_api ? api_source : ui_source
              
                  Elasticsearch::DSL::Search.search do
              Severity: Minor
              Found in lib/elastic_searcher.rb - About 1 hr to fix

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

                    def as_indexed_json(_options = {}) # rubocop:disable Metrics/MethodLength
                      if (latest_version = versions.most_recent)
                        deps = latest_version.dependencies.to_a
                        versioned_links = links(latest_version)
                      end
                Severity: Minor
                Found in app/models/concerns/rubygem_searchable.rb - About 1 hr to fix

                  Method compute_compact_index_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def compute_compact_index_info
                      requirements_and_dependencies.map do |r|
                        deps = []
                        if r[DEPENDENCY_REQUIREMENTS_INDEX]
                          reqs = r[DEPENDENCY_REQUIREMENTS_INDEX].split("@")
                  Severity: Minor
                  Found in app/models/gem_info.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 payload has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def payload(version = most_recent_version, protocol = Gemcutter::PROTOCOL, host_with_port = Gemcutter::HOST)
                      versioned_links = links(version)
                      deps = version.dependencies.to_a
                      {
                        "name"               => name,
                  Severity: Minor
                  Found in app/models/rubygem.rb - About 1 hr to fix

                    Method call has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def call(data)
                            data.delete(:path)
                            {
                              timestamp: ::Time.now.utc,
                              env: Rails.env,
                    Severity: Minor
                    Found in lib/lograge/formatters/datadog.rb - About 1 hr to fix

                      Method validate_gem_and_version has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def validate_gem_and_version
                          if !@rubygem.hosted?
                            render plain: t(:this_rubygem_could_not_be_found),
                                   status: :not_found
                          elsif !@rubygem.owned_by?(@api_key.user)
                      Severity: Minor
                      Found in app/controllers/api/v1/deletions_controller.rb - About 45 mins 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 unique_hook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def unique_hook
                          if user && rubygem
                            if WebHook.exists?(user_id: user.id,
                                               rubygem_id: rubygem.id,
                                               url: url)
                      Severity: Minor
                      Found in app/models/web_hook.rb - About 45 mins 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 find has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def find
                          name = spec.name.to_s
                      
                          @rubygem = Rubygem.name_is(name).first || Rubygem.new(name: name)
                      
                      
                      Severity: Minor
                      Found in app/models/pusher.rb - About 45 mins 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 revoke has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def revoke
                          key_id = request.headers.fetch("GITHUB-PUBLIC-KEY-IDENTIFIER", "")
                          signature = request.headers.fetch("GITHUB-PUBLIC-KEY-SIGNATURE", "")
                      
                          return render plain: "Missing GitHub Signature", status: :unauthorized if key_id.blank? || signature.blank?
                      Severity: Minor
                      Found in app/controllers/api/v1/github_secret_scanning_controller.rb - About 45 mins 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 metadata_attribute_length has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def metadata_attribute_length
                          return if metadata.blank?
                      
                          max_key_size = 128
                          max_value_size = 1024
                      Severity: Minor
                      Found in app/models/version.rb - About 35 mins 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def create
                          return render_api_key_forbidden unless @api_key.can_add_owner?
                      
                          owner = User.find_by_name(params[:email])
                          if owner
                      Severity: Minor
                      Found in app/controllers/api/v1/owners_controller.rb - About 35 mins 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 destroy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def destroy
                          return render_api_key_forbidden unless @api_key.can_remove_owner?
                      
                          owner = @rubygem.owners_including_unconfirmed.find_by_name(params[:email])
                          if owner
                      Severity: Minor
                      Found in app/controllers/api/v1/owners_controller.rb - About 35 mins 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