rubygems/rubygems.org

View on GitHub

Showing 30 of 30 total issues

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

class Version < ApplicationRecord
  belongs_to :rubygem, touch: true
  has_many :dependencies, -> { order('rubygems.name ASC').includes(:rubygem) }, dependent: :destroy, inverse_of: "version"
  has_one :gem_download, proc { |m| where(rubygem_id: m.rubygem_id) }, inverse_of: :version

Severity: Major
Found in app/models/version.rb - About 7 hrs to fix

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

    class Rubygem < ApplicationRecord
      include Patterns
      include RubygemSearchable
    
      has_many :ownerships, dependent: :destroy
    Severity: Major
    Found in app/models/rubygem.rb - About 7 hrs to fix

      File clipboard.js has 392 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /*!
       * clipboard.js v1.5.5
       * https://zenorocha.github.io/clipboard.js
       *
       * Licensed MIT © Zeno Rocha
      Severity: Minor
      Found in lib/assets/javascripts/clipboard.js - About 5 hrs to fix

        Function 8 has 127 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        },{}],8:[function(require,module,exports){
        'use strict';
        
        exports.__esModule = true;
        
        
        Severity: Major
        Found in lib/assets/javascripts/clipboard.js - About 5 hrs to fix

          Function ClipboardAction has 117 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var ClipboardAction = (function () {
              /**
               * @param {Object} options
               */
          
          
          Severity: Major
          Found in lib/assets/javascripts/clipboard.js - About 4 hrs to fix

            Class User has 35 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 4 hrs to fix

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

              require 'digest/sha2'
              
              class Version < ApplicationRecord
                belongs_to :rubygem, touch: true
                has_many :dependencies, -> { order('rubygems.name ASC').includes(:rubygem) }, dependent: :destroy, inverse_of: "version"
              Severity: Minor
              Found in app/models/version.rb - About 3 hrs to fix

                Function 9 has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                },{"select":6}],9:[function(require,module,exports){
                'use strict';
                
                exports.__esModule = true;
                
                
                Severity: Major
                Found in lib/assets/javascripts/clipboard.js - About 2 hrs to fix

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

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

                    Function Clipboard has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    var Clipboard = (function (_Emitter) {
                        _inherits(Clipboard, _Emitter);
                    
                        /**
                         * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
                    Severity: Major
                    Found in lib/assets/javascripts/clipboard.js - About 2 hrs to fix

                      Function 5 has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      },{}],5:[function(require,module,exports){
                      var is = require('./is');
                      var delegate = require('delegate');
                      
                      /**
                      Severity: Minor
                      Found in lib/assets/javascripts/clipboard.js - About 1 hr to fix

                        Function 7 has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        },{}],7:[function(require,module,exports){
                        function E () {
                            // Keep this empty so it's easier to inherit from
                          // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
                        }
                        Severity: Minor
                        Found in lib/assets/javascripts/clipboard.js - About 1 hr to fix

                          Method elastic_search has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              def self.elastic_search(query) # rubocop:disable Metrics/MethodLength
                                search_definition = Elasticsearch::DSL::Search.search do
                                  query do
                                    function_score do
                                      query do
                          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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              function handleClick(event) {
                                var isMobileNavExpanded = header.hasClass(navExpandedClass);
                            
                                event.preventDefault();
                            
                            
                            Severity: Major
                            Found in app/assets/javascripts/mobile-nav.js and 1 other location - About 1 hr to fix
                            app/assets/javascripts/popup-nav.js on lines 15..25

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

                            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

                            Similar blocks of code found in 2 locations. Consider refactoring.
                            Open

                              function handleClick(event) {
                                var isPopupNavExpanded = popupNav.hasClass(navExpandedClass);
                            
                                event.preventDefault();
                            
                            
                            Severity: Major
                            Found in app/assets/javascripts/popup-nav.js and 1 other location - About 1 hr to fix
                            app/assets/javascripts/mobile-nav.js on lines 33..43

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

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

                              def payload(version = versions.most_recent, 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

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                def aggregation_week_count(aggregration)
                                  count = aggregration['buckets'][1]['doc_count']
                                  if count > 0
                                    week_ago = (Time.zone.today - 7.days).to_s(:db)
                                    path = search_path(params: { query: "#{params[:query]} AND updated:[#{week_ago} TO *}" })
                              Severity: Major
                              Found in app/helpers/searches_helper.rb and 1 other location - About 1 hr to fix
                              app/helpers/searches_helper.rb on lines 29..35

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

                              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

                              Similar blocks of code found in 2 locations. Consider refactoring.
                              Open

                                def aggregation_month_count(aggregration)
                                  count = aggregration['buckets'][0]['doc_count']
                                  if count > 0
                                    month_ago = (Time.zone.today - 30.days).to_s(:db)
                                    path = search_path(params: { query: "#{params[:query]} AND updated:[#{month_ago} TO *}" })
                              Severity: Major
                              Found in app/helpers/searches_helper.rb and 1 other location - About 1 hr to fix
                              app/helpers/searches_helper.rb on lines 20..26

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

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

                              Severity
                              Category
                              Status
                              Source
                              Language