NullVoxPopuli/drawers

View on GitHub

Showing 21 of 21 total issues

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

namespace :rmu do
  config_path = "#{Rails.root}/config/initializers/drawers"
  config_exists = File.exist?(config_path)
  require config_path if config_exists

Severity: Minor
Found in lib/tasks/drawers.rake 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 load_missing_constant_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def load_missing_constant_error(from_mod, const_name, e)
      # examples
      # - Api::PostsController
      # - PostsController
      qualified_name = qualified_name_for(from_mod, const_name)
Severity: Minor
Found in lib/drawers/active_support/dependency_extensions.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

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

    def call
      # if this is not part of a resource, don't even bother
      return unless index_of_resource_type

      # Api, V2, Post, Operations, Update
Severity: Minor
Found in lib/drawers/resource_parts.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

Unnecessary utf-8 encoding comment. (https://github.com/bbatsov/ruby-style-guide#utf-8)
Open

# -*- encoding: utf-8 -*-
Severity: Minor
Found in drawers.gemspec by rubocop

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

namespace :rmu do
Severity: Minor
Found in lib/tasks/drawers.rake by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

%w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)
Open

  SINGULAR_RESOURCE_SUFFIXES = %w(
    Serializer
    Operations
    Presenters
    Policy
Severity: Minor
Found in lib/tasks/drawers.rake by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Argument e was shadowed by a local variable before it was used.
Open

      rescue LoadError, NameError => e

This cop checks for shadowed arguments.

Example:

# bad

do_something do |foo|
  foo = 42
  puts foo
end

def do_something(foo)
  foo = 42
  puts foo
end

Example:

# good

do_something do |foo|
  foo = foo + 42
  puts foo
end

def do_something(foo)
  foo = foo + 42
  puts foo
end

def do_something(foo)
  puts foo
end

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

module Drawers
Severity: Minor
Found in lib/drawers/version.rb by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Use %r around regular expression. (https://github.com/bbatsov/ruby-style-guide#percent-r)
Open

    matches = /.+\/(.+\.\w+)/.match(to)
Severity: Minor
Found in lib/tasks/drawers.rake by rubocop

This cop enforces using // or %r around regular expressions.

Example: EnforcedStyle: slashes (default)

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = %r{
  foo
  (bar)
  (baz)
}x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = /
  foo
  (bar)
  (baz)
/x

Example: EnforcedStyle: percent_r

# bad
snake_case = /^[\dA-Z_]+$/

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = %r{^[\dA-Z_]+$}

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: EnforcedStyle: mixed

# bad
snake_case = %r{^[\dA-Z_]+$}

# bad
regex = /
  foo
  (bar)
  (baz)
/x

# good
snake_case = /^[\dA-Z_]+$/

# good
regex = %r{
  foo
  (bar)
  (baz)
}x

Example: AllowInnerSlashes: false (default)

# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.

# bad
x =~ /home\//

# good
x =~ %r{home/}

Example: AllowInnerSlashes: true

# good
x =~ /home\//

required_ruby_version (2.0, declared in drawers.gemspec) and TargetRubyVersion (2.3, declared in .rubocop.yml) should be equal.
Open

  s.required_ruby_version = '>= 2.0'
Severity: Minor
Found in drawers.gemspec by rubocop

Checks that required_ruby_version of gemspec and TargetRubyVersion of .rubocop.yml are equal. Thereby, RuboCop to perform static analysis working on the version required by gemspec.

Example:

# When `TargetRubyVersion` of .rubocop.yml is `2.3`.

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.2.0'
end

# bad
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.4.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3.0'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = '>= 2.3'
end

# good
Gem::Specification.new do |spec|
  spec.required_ruby_version = ['>= 2.3.0', '< 2.5.0']
end

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

source 'https://rubygems.org'
Severity: Minor
Found in Gemfile by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

require 'bundler/gem_tasks'
Severity: Minor
Found in Rakefile by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Dependencies should be sorted in an alphabetical order within their section of the gemspec. Dependency rspec should appear before rubocop.
Open

  s.add_development_dependency 'rspec'
Severity: Minor
Found in drawers.gemspec by rubocop

Dependencies in the gemspec should be alphabetically sorted.

Example:

# bad
spec.add_dependency 'rubocop'
spec.add_dependency 'rspec'

# good
spec.add_dependency 'rspec'
spec.add_dependency 'rubocop'

# good
spec.add_dependency 'rubocop'

spec.add_dependency 'rspec'

# bad
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rspec'

# good
spec.add_development_dependency 'rspec'
spec.add_development_dependency 'rubocop'

# good
spec.add_development_dependency 'rubocop'

spec.add_development_dependency 'rspec'

# bad
spec.add_runtime_dependency 'rubocop'
spec.add_runtime_dependency 'rspec'

# good
spec.add_runtime_dependency 'rspec'
spec.add_runtime_dependency 'rubocop'

# good
spec.add_runtime_dependency 'rubocop'

spec.add_runtime_dependency 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
spec.add_dependency 'rubocop'
# For tests
spec.add_dependency 'rspec'

%w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)
Open

  PLURAL_RESOURCE_SUFFIXES = %w(
    Controller
  ).freeze
Severity: Minor
Found in lib/tasks/drawers.rake by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

module Drawers

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Gems should be sorted in an alphabetical order within their section of the Gemfile. Gem codeclimate-test-reporter should appear before simplecov.
Open

  gem 'codeclimate-test-reporter', group: :test, require: nil
Severity: Minor
Found in Gemfile by rubocop

Gems should be alphabetically sorted within groups.

Example:

# bad
gem 'rubocop'
gem 'rspec'

# good
gem 'rspec'
gem 'rubocop'

# good
gem 'rubocop'

gem 'rspec'

# good only if TreatCommentsAsGroupSeparators is true
# For code quality
gem 'rubocop'
# For tests
gem 'rspec'

%w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)
Open

  DEFAULT_RESOURCE_SUFFIXES = %w(
    Controller
    Forms
    Serializer
    Operations
Severity: Minor
Found in lib/drawers.rb by rubocop

This cop enforces the consistent usage of %-literal delimiters.

Specify the 'default' key to set all preferred delimiters at once. You can continue to specify individual preferred delimiters to override the default.

Example:

# Style/PercentLiteralDelimiters:
#   PreferredDelimiters:
#     default: '[]'
#     '%i':    '()'

# good
%w[alpha beta] + %i(gamma delta)

# bad
%W(alpha #{beta})

# bad
%I(alpha beta)

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

module Drawers
Severity: Minor
Found in lib/drawers/resource_parts.rb by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

module Drawers

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end

Add an empty line after magic comments. (https://github.com/bbatsov/ruby-style-guide#separate-magic-comments-from-code)
Open

require 'rails/railtie'
Severity: Minor
Found in lib/drawers/railtie.rb by rubocop

Checks for a newline after the final magic comment.

Example:

# good
# frozen_string_literal: true

# Some documentation for Person
class Person
  # Some code
end

# bad
# frozen_string_literal: true
# Some documentation for Person
class Person
  # Some code
end
Severity
Category
Status
Source
Language