ApiBootstraper/Rails-server

View on GitHub

Showing 4 of 4 total issues

Method respond_with has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def respond_with(content, *resources)
    options = resources.size == 0 ? {} : resources.extract_options!
    options[:status] = {} if options[:status].nil?

    # Format status
Severity: Minor
Found in app/controllers/api/base_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 api_offset_and_limit has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def api_offset_and_limit(options=params)
    offset = 0

    if options[:offset].present?
      offset = options[:offset].to_i
Severity: Minor
Found in app/controllers/api/base_controller.rb - About 55 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 params_filter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def params_filter params, filters
    return params unless filters.kind_of?(Array)
    return params unless params.kind_of?(Hash)
    res = {}
    filters.each { |k| res[k] = params[k] unless params[k].nil? }
Severity: Minor
Found in app/controllers/api/v100/base_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 change_accomplishment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def change_accomplishment
    todo = Todo.find_by_uuid!(params[:uuid])
    return respond_with(nil, :status => {:msg => "You are not the author of this todo, you can't check it", :code => 403}) unless current_user === todo.user

    todo.is_accomplished = params[:state] === 'check' ? true : false
Severity: Minor
Found in app/controllers/api/v100/todos_controller.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

Severity
Category
Status
Source
Language