xiaohui-zhangxh/editor_js

View on GitHub
lib/editor_js/blocks/image_block.rb

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Assignment Branch Condition size for render is too high. [26.59/15]
Open

      def render(_options = {})
        content_tag :div, class: css_name do
          url = data['url']
          caption = data['caption']
          withBorder = data['withBorder']
Severity: Minor
Found in lib/editor_js/blocks/image_block.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. [15/10]
Open

      def render(_options = {})
        content_tag :div, class: css_name do
          url = data['url']
          caption = data['caption']
          withBorder = data['withBorder']
Severity: Minor
Found in lib/editor_js/blocks/image_block.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

      def render(_options = {})
        content_tag :div, class: css_name do
          url = data['url']
          caption = data['caption']
          withBorder = data['withBorder']
Severity: Minor
Found in lib/editor_js/blocks/image_block.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

end at 42, 22 is not aligned with html_str = content_tag :div, class: html_class do at 40, 10.
Open

                      end
Severity: Minor
Found in lib/editor_js/blocks/image_block.rb by rubocop

This cop checks whether the end keywords are aligned properly for do end blocks.

Three modes are supported through the EnforcedStyleAlignWith configuration parameter:

start_of_block : the end shall be aligned with the start of the line where the do appeared.

start_of_line : the end shall be aligned with the start of the line where the expression started.

either (which is the default) : the end is allowed to be in either location. The autofixer will default to start_of_line.

Example: EnforcedStyleAlignWith: either (default)

# bad

foo.bar
   .each do
     baz
       end

# good

variable = lambda do |i|
  i
end

Example: EnforcedStyleAlignWith: startofblock

# bad

foo.bar
   .each do
     baz
       end

# good

foo.bar
  .each do
     baz
   end

Example: EnforcedStyleAlignWith: startofline

# bad

foo.bar
   .each do
     baz
       end

# good

foo.bar
  .each do
     baz
end

Use snake_case for variable names.
Open

          withBorder = data['withBorder']
Severity: Minor
Found in lib/editor_js/blocks/image_block.rb by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Use snake_case for variable names.
Open

          withBackground = data['withBackground']
Severity: Minor
Found in lib/editor_js/blocks/image_block.rb by rubocop

This cop makes sure that all variables use the configured style, snake_case or camelCase, for their names.

Example: EnforcedStyle: snake_case (default)

# bad
fooBar = 1

# good
foo_bar = 1

Example: EnforcedStyle: camelCase

# bad
foo_bar = 1

# good
fooBar = 1

Line is too long. [99/80]
Open

          html_str << content_tag(:div, caption.html_safe, class: "#{css_name}__caption").html_safe
Severity: Minor
Found in lib/editor_js/blocks/image_block.rb by rubocop

Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
Open

          if key == 'url'
Severity: Minor
Found in lib/editor_js/blocks/image_block.rb by rubocop

Checks for if and unless statements that would fit on one line if written as a modifier if/unless. The maximum line length is configured in the Metrics/LineLength cop.

Example:

# bad
if condition
  do_stuff(bar)
end

unless qux.empty?
  Foo.do_something
end

# good
do_stuff(bar) if condition
Foo.do_something unless qux.empty?

Line is too long. [82/80]
Open

          html_class += " #{css_name}__picture--with-background" if withBackground
Severity: Minor
Found in lib/editor_js/blocks/image_block.rb by rubocop

There are no issues that match your filters.

Category
Status