Showing 116 of 116 total issues
Assignment Branch Condition size for perform_batch_action is too high. [33.3/15] Open
def perform_batch_action
return unless params[:batch_action].present?
set_resource_service
set_resource_class
- Read upRead up
- Exclude checks
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
File template.rb
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "active_support/all"
def install_standalone
set_ruby_version
Assignment Branch Condition size for column_header is too high. [22.58/15] Open
def column_header(attribute)
if @resource_service.orderable_column?(attribute.to_s)
direction =
if params[:order].present?
if params[:order].match(/\A#{attribute.to_s}_(asc|desc)\z/)
- Read upRead up
- Exclude checks
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
Function BatchActions
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
Godmin.BatchActions = (function() {
var $container;
var $selectAll;
var $selectNone;
Method has too many lines. [29/25] Open
def filter_select(name, options, html_options)
unless options[:collection].is_a? Proc
raise "A collection proc must be specified for select filters"
end
- Read upRead up
- Exclude checks
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 filter_select is too high. [19.34/15] Open
def filter_select(name, options, html_options)
unless options[:collection].is_a? Proc
raise "A collection proc must be specified for select filters"
end
- Read upRead up
- Exclude checks
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
Assignment Branch Condition size for include_batch_action? is too high. [18.71/15] Open
def include_batch_action?(action)
options = batch_action_map[action.to_sym]
(options[:only].nil? && options[:except].nil?) ||
(options[:only] && options[:only].include?(scope.to_sym)) ||
- Read upRead up
- Exclude checks
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
Assignment Branch Condition size for pages is too high. [18.49/15] Open
def pages
@pages ||= begin
pages = (1..total_pages).to_a
return pages unless total_pages > WINDOW_SIZE
- Read upRead up
- Exclude checks
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 column_header
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def column_header(attribute)
if @resource_service.orderable_column?(attribute.to_s)
direction =
if params[:order].present?
if params[:order].match(/\A#{attribute.to_s}_(asc|desc)\z/)
- Read upRead up
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
Assignment Branch Condition size for navbar_item is too high. [17.97/15] Open
def navbar_item(resource, url = resource, show: nil, icon: nil, **options)
show ||= lambda do
resource.is_a?(String) ? true : policy(resource).index?
end
- Read upRead up
- Exclude checks
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
Perceived complexity for column_header is too high. [9/7] Open
def column_header(attribute)
if @resource_service.orderable_column?(attribute.to_s)
direction =
if params[:order].present?
if params[:order].match(/\A#{attribute.to_s}_(asc|desc)\z/)
- Read upRead up
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method modify_article_service
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def modify_article_service(namespace = nil)
article_service =
if namespace
"admin/app/services/admin/article_service.rb"
else
Function Datetimepickers
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Godmin.Datetimepickers = (function() {
function initialize() {
initializeEvents();
initializeState();
}
Function Navigation
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Godmin.Navigation = (function() {
function initialize() {
initializeEvents();
initializeState();
}
Method install_engine
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def install_engine
set_ruby_version
run_ruby_script("bin/rails plugin new admin --mountable")
Method filter_select
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def filter_select(name, options, html_options)
unless options[:collection].is_a? Proc
raise "A collection proc must be specified for select filters"
end
Method generate_models
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_models
generate(:model, "author name:string")
generate(:model, "article title:string body:text author:references published:boolean published_at:datetime")
gsub_file Dir.glob("db/migrate/*_create_articles.rb").first, "t.boolean :published", "t.boolean :published, default: false"
Method navbar_item
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def navbar_item(resource, url = resource, show: nil, icon: nil, **options)
show ||= lambda do
resource.is_a?(String) ? true : policy(resource).index?
end
- Read upRead up
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
Block has too many lines. [32/25] Open
Gem::Specification.new do |gem|
gem.name = "godmin"
gem.version = Godmin::VERSION
gem.authors = ["Jens Ljungblad", "Linus Pettersson", "Varvet"]
gem.email = ["info@varvet.se"]
- Read upRead up
- Exclude checks
This cop checks if the length of a block exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable. The cop can be configured to ignore blocks passed to certain methods.
Function BatchActions
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Godmin.BatchActions = (function() {
var $container;
var $selectAll;
var $selectNone;
- Read upRead up
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"