SpeciesFileGroup/taxonworks

View on GitHub
app/controllers/topics_controller.rb

Summary

Maintainability
A
1 hr
Test Coverage

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

  def create
    @controlled_vocabulary_term = ControlledVocabularyTerm.new(controlled_vocabulary_term_params)
    respond_to do |format|
      if @controlled_vocabulary_term.save
        msg = "#{@controlled_vocabulary_term.type} '#{@controlled_vocabulary_term.name}' was successfully created."
Severity: Minor
Found in app/controllers/topics_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

Use params.permit(:return_path)[:return_path].present? instead of !params.permit(:return_path)[:return_path].blank?.
Open

        if !params.permit(:return_path)[:return_path].blank?

This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

Example: NotNilAndNotEmpty: true (default)

# Converts usages of `!nil? && !empty?` to `present?`

# bad
!foo.nil? && !foo.empty?

# bad
foo != nil && !foo.empty?

# good
foo.present?

Example: NotBlank: true (default)

# Converts usages of `!blank?` to `present?`

# bad
!foo.blank?

# bad
not foo.blank?

# good
foo.present?

Example: UnlessBlank: true (default)

# Converts usages of `unless blank?` to `if present?`

# bad
something unless foo.blank?

# good
something if foo.present?

TODO found
Open

  # TODO: deprecate fully
Severity: Minor
Found in app/controllers/topics_controller.rb by fixme

TODO found
Open

  # TODO: deprecate for index?  List should be paginated.
Severity: Minor
Found in app/controllers/topics_controller.rb by fixme

TODO found
Open

        label:  t.name # TODO: referenced in js picker, refactor to use name rather than label
Severity: Minor
Found in app/controllers/topics_controller.rb by fixme

There are no issues that match your filters.

Category
Status