drapergem/draper

View on GitHub

Showing 10 of 213 total issues

Class has too many lines. [128/100]
Open

  class Decorator
    include Draper::ViewHelpers
    include Draper::Compatibility::GlobalID if defined?(GlobalID)
    extend Draper::Delegation

Severity: Minor
Found in lib/draper/decorator.rb by rubocop

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Block has too many lines. [76/25]
Open

m = Module.new do
  module_function

  def invoked_as_script?
    File.expand_path($0) == File.expand_path(__FILE__)
Severity: Minor
Found in bin/bundle by rubocop

This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

Class Decorator has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Decorator
    include Draper::ViewHelpers
    include Draper::Compatibility::GlobalID if defined?(GlobalID)
    extend Draper::Delegation

Severity: Minor
Found in lib/draper/decorator.rb - About 3 hrs to fix

    Method has too many lines. [13/10]
    Open

      def cli_arg_version
        return unless invoked_as_script? # don't want to hijack other binstubs
        return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
        bundler_version = nil
        update_index = nil
    Severity: Minor
    Found in bin/bundle by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Cyclomatic complexity for cli_arg_version is too high. [8/6]
    Open

      def cli_arg_version
        return unless invoked_as_script? # don't want to hijack other binstubs
        return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
        bundler_version = nil
        update_index = nil
    Severity: Minor
    Found in bin/bundle by rubocop

    This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

    An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

    Perceived complexity for cli_arg_version is too high. [8/7]
    Open

      def cli_arg_version
        return unless invoked_as_script? # don't want to hijack other binstubs
        return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
        bundler_version = nil
        update_index = nil
    Severity: Minor
    Found in bin/bundle by rubocop

    This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

    Example:

    def my_method                   # 1
      if cond                       # 1
        case var                    # 2 (0.8 + 4 * 0.2, rounded)
        when 1 then func_one
        when 2 then func_two
        when 3 then func_three
        when 4..10 then func_other
        end
      else                          # 1
        do_something until a && b   # 2
      end                           # ===
    end                             # 7 complexity points

    Assignment Branch Condition size for activate_bundler is too high. [16.4/15]
    Open

      def activate_bundler
        gem_error = activation_error_handling do
          gem "bundler", bundler_requirement
        end
        return if gem_error.nil?
    Severity: Minor
    Found in bin/bundle by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Block has too many lines. [30/25]
    Open

    namespace "spec" do
      task "all" => ["draper", "generators", "integration"]
    
      def spec_task(name)
        desc "Run #{name} specs"
    Severity: Minor
    Found in Rakefile by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Method decorator_class has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def decorator_class(called_on = self)
            prefix = respond_to?(:model_name) ? model_name : name
            decorator_name = "#{prefix}Decorator"
            decorator_name_constant = decorator_name.safe_constantize
            return decorator_name_constant unless decorator_name_constant.nil?
    Severity: Minor
    Found in lib/draper/decoratable.rb - About 25 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

    Block has too many lines. [26/25]
    Open

    Gem::Specification.new do |s|
      s.name        = "draper"
      s.version     = Draper::VERSION
      s.authors     = ["Jeff Casimir", "Steve Klabnik"]
      s.email       = ["jeff@casimircreative.com", "steve@steveklabnik.com"]
    Severity: Minor
    Found in draper.gemspec by rubocop

    This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.

    Severity
    Category
    Status
    Source
    Language