Showing 200 of 201 total issues
Class has too many lines. [222/100] Open
class PaginationModel
@debug = false # is debug output enabled?
@logging_lambda = nil # The lambda to use for logging
@page_add_lambda = nil # The lambda used to create pages and add them to the site
- Read upRead up
- Exclude checks
This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method paginate
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales)
# By default paginate on all posts in the site
using_posts = all_posts
should_union = config['combine'] == 'union'
- 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
Method paginate
has 96 lines of code (exceeds 25 allowed). Consider refactoring. Open
def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales)
# By default paginate on all posts in the site
using_posts = all_posts
should_union = config['combine'] == 'union'
Method generate
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def generate(site)
#begin
# Generate the AutoPages first
PaginateV2::AutoPages.create_autopages(site)
- 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
Method index_posts_by
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.index_posts_by(all_posts, index_key)
return nil if all_posts.nil?
return all_posts if index_key.nil?
index = {}
all_posts.each do |post|
- 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
Method ap_index_posts_by
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def self.ap_index_posts_by(all_posts, index_key)
return nil if all_posts.nil?
return all_posts if index_key.nil?
index = {}
all_posts.each do |post|
- 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
Method initialize
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def initialize(config_per_page, first_index_page_url, paginated_page_url, posts, cur_page_nr, num_pages, default_indexpage, default_ext)
@page = cur_page_nr
@per_page = config_per_page.to_i
@total_pages = num_pages
- 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 paginate is too high. [176.5/165] Open
def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales)
# By default paginate on all posts in the site
using_posts = all_posts
should_union = config['combine'] == 'union'
- 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 generate
has 70 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate(site)
#begin
# Generate the AutoPages first
PaginateV2::AutoPages.create_autopages(site)
Perceived complexity for paginate is too high. [32/30] Open
def paginate(template, config, site_title, all_posts, all_tags, all_categories, all_locales)
# By default paginate on all posts in the site
using_posts = all_posts
should_union = config['combine'] == 'union'
- 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 _debug_print_config_info
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def _debug_print_config_info(config, page_path)
r = 20
f = "Pagination: ".rjust(20)
# Debug print the config
if @debug
- 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
Method autopages_log
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def self.autopages_log(config, *config_keys)
enabled, disabled = [], []
config_keys.each do |key|
key_config = config[key] # config for key
next if config.nil? || key_config['silent']
- 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
Method run
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def run(default_config, site_pages, site_title)
# By default if pagination is enabled we attempt to find all index.html pages in the site
templates = self.discover_paginate_templates(site_pages)
if( templates.size.to_i <= 0 )
@logging_lambda.call "Is enabled, but I couldn't find any pagination page. Skipping pagination. "+
- 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
Method initialize
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda, display_name)
Method initialize
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(config_per_page, first_index_page_url, paginated_page_url, posts, cur_page_nr, num_pages, default_indexpage, default_ext)
@page = cur_page_nr
@per_page = config_per_page.to_i
@total_pages = num_pages
Method read_config_value_and_filter_posts
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def self.read_config_value_and_filter_posts(config, config_key, posts, source_posts, should_union = false)
return nil if posts.nil?
return nil if source_posts.nil? # If the source is empty then simply don't do anything
return posts if config.nil?
return posts if !config.has_key?(config_key)
- 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
Method _debug_print_config_info
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def _debug_print_config_info(config, page_path)
r = 20
f = "Pagination: ".rjust(20)
# Debug print the config
if @debug
Method initialize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(site, base, autopage_config, pagination_config, layout_name, set_autopage_data_lambda, get_autopage_permalink_lambda, get_autopage_title_lambda, display_name)
@site = site
@base = base
@name = 'index.html'
Method run
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run(default_config, site_pages, site_title)
# By default if pagination is enabled we attempt to find all index.html pages in the site
templates = self.discover_paginate_templates(site_pages)
if( templates.size.to_i <= 0 )
@logging_lambda.call "Is enabled, but I couldn't find any pagination page. Skipping pagination. "+
Method initialize
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(config_per_page, first_index_page_url, paginated_page_url, posts, cur_page_nr, num_pages, default_indexpage, default_ext)