shammond42/higgins-catalog

View on GitHub
app/controllers/artifacts_controller.rb

Summary

Maintainability
A
1 hr
Test Coverage

Method index has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    query = params[:query].present? ? params[:query] : ''
    # filter_params
    low_date = params[:low_date].present? ? params[:low_date].to_i : -10_000
    high_date = params[:high_date].present? ? params[:high_date].to_i : 10_000
Severity: Minor
Found in app/controllers/artifacts_controller.rb - About 35 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

Method filter_params has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def filter_params
    if(params[:query] =~ DATE_RANGE_REGEX)
      params[:low_date] = $2
      params[:high_date] = $3
      params[:keyword] = params[:query].sub(DATE_RANGE_REGEX,'')
Severity: Minor
Found in app/controllers/artifacts_controller.rb - About 35 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

Method show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @artifact = Artifact.includes(:questions, :artifact_images).find_by_accession_number(params[:id])

    if @artifact.nil?
      not_found
Severity: Minor
Found in app/controllers/artifacts_controller.rb - About 35 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

There are no issues that match your filters.

Category
Status