publiclab/plots2

View on GitHub
app/controllers/user_tags_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method create has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @output = {
      errors: [],
      saved: []
    }
Severity: Minor
Found in app/controllers/user_tags_controller.rb - About 4 hrs 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 create has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    @output = {
      errors: [],
      saved: []
    }
Severity: Minor
Found in app/controllers/user_tags_controller.rb - About 2 hrs to fix

Method delete has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def delete
    output = {
      status: false,
      tid: 0,
      errors: []
Severity: Minor
Found in app/controllers/user_tags_controller.rb - About 1 hr 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 delete has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def delete
    output = {
      status: false,
      tid: 0,
      errors: []
Severity: Minor
Found in app/controllers/user_tags_controller.rb - About 1 hr to fix

Use && instead of and.
Open

      redirect_to URI.parse('/change_locale/en').path and return

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

Use && instead of and.
Open

        redirect_to URI.parse('/change_locale/zh-CN').path and return

This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

Example: EnforcedStyle: always (default)

# bad
foo.save and return

# bad
if foo and bar
end

# good
foo.save && return

# good
if foo && bar
end

Example: EnforcedStyle: conditionals

# bad
if foo and bar
end

# good
foo.save && return

# good
foo.save and return

# good
if foo && bar
end

There are no issues that match your filters.

Category
Status