Showing 12 of 761 total issues
Class UserSession
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class UserSession
attr_reader :session, :token
TTL = 4 * 60 * 60
@@ttl = TTL
Class Manifest
has 29 methods (exceeds 20 allowed). Consider refactoring. Open
class Manifest < ActiveRecord::Base
include Searchable
validate :tracking_number, :validate_tracking_number_unique
validates :user_id, presence: true
Class QueryDSL
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
class QueryDSL
include Elasticsearch::DSL
MAX_RESULTS = 100
Method us_states
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
def us_states
[
['Alabama', 'AL'],
['Alaska', 'AK'],
['Arizona', 'AZ'],
Method to_h
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_h
hash = {}
if field_pairs
field_pairs.each do |k, v|
next if v.nil?
- Read upRead up
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 to_s
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def to_s
clauses = []
if field_pairs
field_pairs.each do |k, v|
next if v.nil?
- Read upRead up
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 deep_reject!
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def deep_reject!(hash, &block)
hash.each do |k, v|
if (v.is_a?(Hash) || v.is_a?(ActionController::Parameters))
deep_reject!(v, &block)
elsif v.is_a?(Array)
- Read upRead up
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 mexican_states
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def mexican_states
[
['Aguascalientes', 'MX - AG'],
['Baja California', 'MX - BN'],
['Baja California Sur', 'MX - BS'],
Method profile_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def profile_field(json_xpath)
fields = json_xpath.split('.')
if profile && fields.inject(profile) { |h,k| h[k] if h }
fields.inject(profile) { |h,k| h[k] if h }
end
- Read upRead up
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 content_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def content_field(json_xpath)
fields = json_xpath.split('.')
if content && fields.inject(content) { |h,k| h[k] if h }
fields.inject(content) { |h,k| h[k] if h }
end
- Read upRead up
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 6 (exceeds 5 allowed). Consider refactoring. Open
def create
authenticate_user!
unless performed?
@manifest = Manifest.new(content: manifest_params, user: current_user)
- Read upRead up
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 show
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def show
manifest = find_manifest
if has_permission_to_view?(manifest)
unless performed?
render json: ManifestSerializer.new(manifest).to_json
- Read upRead up
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"