lib/field_mappings.rb

Summary

Maintainability
A
0 mins
Test Coverage

Assignment Branch Condition size for used_by_items? is too high. [26.78/15]
Open

    def used_by_items?
      # Check whether we are dealing with a topic type mapping
      # or a content type mapping and get items accordingly
      @all_versions ||=
        if is_a?(TopicTypeToFieldMapping)
Severity: Minor
Found in lib/field_mappings.rb 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

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

    def used_by_items?
      # Check whether we are dealing with a topic type mapping
      # or a content type mapping and get items accordingly
      @all_versions ||=
        if is_a?(TopicTypeToFieldMapping)
Severity: Minor
Found in lib/field_mappings.rb 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.

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

    def self.included(klass)
      # RABID: it seems this module can only be included in 2 classes
      case klass.name
      when 'ContentTypeToFieldMapping'
        klass.send :belongs_to, :content_type
Severity: Minor
Found in lib/field_mappings.rb 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.

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

    def used_by_items?
      # Check whether we are dealing with a topic type mapping
      # or a content type mapping and get items accordingly
      @all_versions ||=
        if is_a?(TopicTypeToFieldMapping)
Severity: Minor
Found in lib/field_mappings.rb 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

Avoid single-line method definitions.
Open

    def extended_field_xsi_type;             extended_field.xsi_type; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Pass &:id as an argument to collect instead of a block.
Open

          Topic::Version.all(conditions: { topic_type_id: topic_type.full_set.collect { |tt| tt.id } })
Severity: Minor
Found in lib/field_mappings.rb by rubocop

Use symbols as procs when possible.

Example:

# bad
something.map { |s| s.upcase }

# good
something.map(&:upcase)

Use %r around regular expression.
Open

          version.extended_content !~ /<#{element_label}[^>]*>(<[0-9]+><#{ef_label}[^>]*><\/#{ef_label}><\/[0-9]+>)*<\/#{element_label}>/
Severity: Minor
Found in lib/field_mappings.rb 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\//

Avoid single-line method definitions.
Open

    def extended_field_xml_element_name;     extended_field.xml_element_name; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Avoid single-line method definitions.
Open

    def extended_field_multiple;             extended_field.multiple; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

end at 80, 31 is not aligned with if at 72, 8.
Open

                               end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks whether the end keywords are aligned properly.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

If it's set to keyword (which is the default), the end shall be aligned with the start of the keyword (if, class, etc.).

If it's set to variable the end shall be aligned with the left-hand-side of the variable assignment, if there is one.

If it's set to start_of_line, the end shall be aligned with the start of the line where the matching keyword appears.

Example: EnforcedStyleAlignWith: keyword (default)

# bad

variable = if true
    end

# good

variable = if true
           end

Example: EnforcedStyleAlignWith: variable

# bad

variable = if true
    end

# good

variable = if true
end

Example: EnforcedStyleAlignWith: startofline

# bad

variable = if true
    end

# good

puts(if true
end)

Use %r around regular expression.
Open

          version.extended_content !~ /<#{element_label}[^>]*\/>/ &&
Severity: Minor
Found in lib/field_mappings.rb 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\//

Avoid single-line method definitions.
Open

    def extended_field_description;          extended_field.description; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Convert if nested inside else to elsif.
Open

          if content_type.class_name == 'User'
Severity: Minor
Found in lib/field_mappings.rb by rubocop

If the else branch of a conditional consists solely of an if node, it can be combined with the else to become an elsif. This helps to keep the nesting level from getting too deep.

Example:

# bad
if condition_a
  action_a
else
  if condition_b
    action_b
  else
    action_c
  end
end

# good
if condition_a
  action_a
elsif condition_b
  action_b
else
  action_c
end

Avoid single-line method definitions.
Open

    def extended_field_label;                extended_field.label; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Avoid single-line method definitions.
Open

    def extended_field_user_choice_addition; extended_field.user_choice_addition; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

Avoid single-line method definitions.
Open

    def extended_field_ftype;                extended_field.ftype; end
Severity: Minor
Found in lib/field_mappings.rb by rubocop

This cop checks for single-line method definitions that contain a body. It will accept single-line methods with no body.

Example:

# bad
def some_method; body end
def link_to(url); {:name => url}; end
def @table.columns; super; end

# good
def no_op; end
def self.resource_class=(klass); end
def @table.columns; end

There are no issues that match your filters.

Category
Status