metamaps/metamaps

View on GitHub
app/controllers/synapses_controller.rb

Summary

Maintainability
A
35 mins
Test Coverage

Method has too many lines. [17/10]
Open

  def create
    @synapse = Synapse.new(synapse_params)
    @synapse.desc = '' if @synapse.desc.nil?
    @synapse.desc.strip! # no trailing/leading whitespace
    @synapse.user = current_user

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.

Assignment Branch Condition size for create is too high. [19.21/16]
Open

  def create
    @synapse = Synapse.new(synapse_params)
    @synapse.desc = '' if @synapse.desc.nil?
    @synapse.desc.strip! # no trailing/leading whitespace
    @synapse.user = current_user

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. [12/10]
Open

  def update
    @synapse = Synapse.find(params[:id])
    @synapse.desc = '' if @synapse.desc.nil?
    authorize @synapse
    @synapse.updated_by = current_user

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.

Assignment Branch Condition size for update is too high. [16.4/16]
Open

  def update
    @synapse = Synapse.find(params[:id])
    @synapse.desc = '' if @synapse.desc.nil?
    authorize @synapse
    @synapse.updated_by = current_user

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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @synapse = Synapse.new(synapse_params)
    @synapse.desc = '' if @synapse.desc.nil?
    @synapse.desc.strip! # no trailing/leading whitespace
    @synapse.user = current_user
Severity: Minor
Found in app/controllers/synapses_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

index is not explicitly defined on the controller.
Open

  after_action :verify_policy_scoped, only: :index

This cop checks that methods specified in the filter's only or except options are explicitly defined in the controller.

You can specify methods of superclass or methods added by mixins on the filter, but these confuse developers. If you specify methods where are defined on another controller, you should define the filter in that controller.

Example:

# bad
class LoginController < ApplicationController
  before_action :require_login, only: %i[index settings logout]

  def index
  end
end

# good
class LoginController < ApplicationController
  before_action :require_login, only: %i[index settings logout]

  def index
  end

  def settings
  end

  def logout
  end
end

index is not explicitly defined on the controller.
Open

  after_action :verify_authorized, except: :index

This cop checks that methods specified in the filter's only or except options are explicitly defined in the controller.

You can specify methods of superclass or methods added by mixins on the filter, but these confuse developers. If you specify methods where are defined on another controller, you should define the filter in that controller.

Example:

# bad
class LoginController < ApplicationController
  before_action :require_login, only: %i[index settings logout]

  def index
  end
end

# good
class LoginController < ApplicationController
  before_action :require_login, only: %i[index settings logout]

  def index
  end

  def settings
  end

  def logout
  end
end

There are no issues that match your filters.

Category
Status