Method bulk
has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring. Open
def bulk
@report = {
success: [],
failed: [],
duplicate_public: false,
- Read upRead up
- Create a ticketCreate a ticket
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
File nodes_controller.rb
has 545 lines of code (exceeds 250 allowed). Consider refactoring. Open
class NodesController < ApplicationController
# allow node polling during the upgrade
skip_before_filter :upgrade, only: [:index]
api :GET, "/nodes", "List all nodes and their status"
- Create a ticketCreate a ticket
Method get_node_and_network
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def get_node_and_network(node_name)
network = {}
@network = []
@node = Node.find_by_name(node_name) if @node.nil?
if @node
- Read upRead up
- Create a ticketCreate a ticket
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 bulk
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
def bulk
@report = {
success: [],
failed: [],
duplicate_public: false,
- Create a ticketCreate a ticket
Method save_node
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def save_node
if params[:group] and params[:group] != "" and !(params[:group] =~ /^[a-zA-Z][a-zA-Z0-9._:-]+$/)
flash[:alert] = t("nodes.list.group_error", failed: @node.name)
return false
end
- Read upRead up
- Create a ticketCreate a ticket
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
Consider simplifying this complex logical expression. Open
if (params[:raid_type] == "raid1" && raid_disks_selected < 2) || \
(params[:raid_type] == "raid0" && raid_disks_selected < 1) || \
(params[:raid_type] == "raid5" && raid_disks_selected < 3) || \
(params[:raid_type] == "raid6" && raid_disks_selected < 4) || \
(params[:raid_type] == "raid10" && raid_disks_selected < 4)
- Create a ticketCreate a ticket
Method save_node
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
def save_node
if params[:group] and params[:group] != "" and !(params[:group] =~ /^[a-zA-Z][a-zA-Z0-9._:-]+$/)
flash[:alert] = t("nodes.list.group_error", failed: @node.name)
return false
end
- Create a ticketCreate a ticket
Method status
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def status
@result = {
nodes: {},
groups: {}
}.tap do |result|
- Create a ticketCreate a ticket
Method get_node_and_network
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def get_node_and_network(node_name)
network = {}
@network = []
@node = Node.find_by_name(node_name) if @node.nil?
if @node
- Create a ticketCreate a ticket
Method hit
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def hit
name = params[:name] || params[:id]
machine = Node.find_by_name(name)
respond_to do |format|
- Read upRead up
- Create a ticketCreate a ticket
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 update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update
unless request.post?
raise ActionController::UnknownHttpMethod.new("POST is required to update proposal #{params[:id]}")
end
- Read upRead up
- Create a ticketCreate a ticket
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 hit
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def hit
name = params[:name] || params[:id]
machine = Node.find_by_name(name)
respond_to do |format|
- Create a ticketCreate a ticket
Method show
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show
get_node_and_network(params[:id] || params[:name])
if @node.nil?
msg = "Node #{params[:id] || params[:name]}: not found"
if request.format == "html"
- Read upRead up
- Create a ticketCreate a ticket
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 index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def index
@sum = 0
@groups = {}
session[:node] = params[:name]
if params.key?(:role)
- Read upRead up
- Create a ticketCreate a ticket
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 get_nodes_and_groups
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_nodes_and_groups(node_name, draggable = true)
@sum = 0
@groups = {}
@nodes = {}
raw_nodes = Node.all
- Read upRead up
- Create a ticketCreate a ticket
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"