Showing 26 of 26 total issues
Function pjax
has 145 lines of code (exceeds 25 allowed). Consider refactoring. Open
var pjax = $.pjax = function( options ) {
// options from handleClick fn
options = $.extend({}, $.ajaxSettings, pjax.defaults, options);
File _zepto.pjax.js
has 378 lines of code (exceeds 250 allowed). Consider refactoring. Open
// zepto.pjax.js
// copyright chris wanstrath
// https://github.com/defunkt/jquery-pjax
// https://github.com/shogun70/jquery-pjax - duration
// https://github.com/jimisaacs/zepto-pjax
Method manipulate_resource_list
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def manipulate_resource_list(resources)
@_articles = []
used_resources = []
resources.each do |resource|
- 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 article
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def article
@content = options[:content] || ''
@date = options[:date] ? ::Time.zone.parse(options[:date]) : Time.zone.now
@locale = options[:locale] || (::I18n.default_locale if defined? ::I18n)
@slug = safe_parameterize(title)
- 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 manipulate_resource_list
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def manipulate_resource_list(resources)
new_resources = []
resources.each do |res|
next if res.ignored?
- 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 after_configuration
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def after_configuration
@name ||= begin
found_name = nil
app.extensions[:blog].values.each_with_index do |ext, i|
- 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 blog_controller
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def blog_controller(blog_name = nil)
if !blog_name && current_resource
blog_name = current_resource.metadata[:page][:blog]
unless blog_name
- 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 date
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def date
return @_date if @_date
frontmatter_date = data['date']
- 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 after_configuration
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def after_configuration
@name ||= begin
found_name = nil
app.extensions[:blog].values.each_with_index do |ext, i|
Function beforeSend
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
options.beforeSend = function(xhr, settings) {
var timeout = settings.timeout;
if (settings.timeout > 0) {
timeoutTimer = setTimeout(function() {
if (fire('pjax:timeout', [xhr, options]))
Method article
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def article
@content = options[:content] || ''
@date = options[:date] ? ::Time.zone.parse(options[:date]) : Time.zone.now
@locale = options[:locale] || (::I18n.default_locale if defined? ::I18n)
@slug = safe_parameterize(title)
Function _success
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _success(data, status, xhr) {
var container = extractContainer(data, xhr, options);
if (!container.contents) {
window.location = container.url;
Method manipulate_resource_list
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def manipulate_resource_list(resources)
@_articles = []
used_resources = []
resources.each do |resource|
Method manipulate_resource_list
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def manipulate_resource_list(resources)
new_resources = []
# Set up date pages if the appropriate templates have been specified
@blog_data.articles.group_by { |a| a.date.year }.each do |year, year_articles|
- 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
Function pjax
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
$.pjax = function( options ) {
var url = $.isFunction(options.url) ? options.url() : options.url,
method = options.type ? options.type.toUpperCase() : 'GET';
var form = $('<form>', {
Method render
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def render(opts = {}, locs = {}, &block)
unless opts.key?(:layout)
opts[:layout] = metadata[:options][:layout]
opts[:layout] = blog_options.layout if opts[:layout].nil? || opts[:layout] == :_auto_layout
- 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 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(app, options_hash = {}, &block)
super
@custom_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
Method page_locals
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def page_locals(page_num, num_pages, per_page, prev_page_res, articles)
Similar blocks of code found in 2 locations. Consider refactoring. Open
activate :blog do |blog2|
blog2.name = 'blog_name_2'
blog2.prefix = 'blog2'
blog2.sources = ':year-:month-:day-:title.html'
blog2.permalink = ':year-:month-:day-:title.html'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
activate :blog do |blog|
blog.name = 'blog_name_1'
blog.prefix = 'blog1'
blog.sources = ':year-:month-:day-:title.html'
blog.permalink = ':year-:month-:day-:title.html'
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 29.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76