Showing 302 of 302 total issues
Method each_parliament_issue
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def each_parliament_issue(parliament_issues, limit = nil)
count = 0
parliament_issues.each_with_index do |parliament_issue, index|
details = parsing_data_source.parliament_issue_details(parliament_issue.external_id)
- 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
Similar blocks of code found in 3 locations. Consider refactoring. Open
function get(url, params, callbacks) {
var options = getOptions.call(this, url, params);
var cbs = getCallbacks.call(this, callbacks);
JZ.ajax.get(options, cbs);
}
- 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 60.
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 3 locations. Consider refactoring. Open
function getJSON(url, params, callbacks) {
var options = getOptions.call(this, url, params);
var cbs = getCallbacks.call(this, callbacks);
JZ.ajax.getJSON(options, cbs);
}
- 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 60.
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
Function loading
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
loading: function (callback) {
callback = callback || function () { };
this.$element
.toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
Method auto_title
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def auto_title
title = plain_body.gsub("\n", " ")
TITLE_RULES.each do |rx, replacement|
title.sub!(rx, replacement)
Method import_api_representatives
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def import_api_representatives
representatives = {}
representatives_today = []
# the information in 'representatives_today' is more complete,
Function doAutoindent
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
commandProto.doAutoindent = function (chunk, postProcessing) {
var commandMgr = this,
fakeSelection = false;
Function findTags
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Chunks.prototype.findTags = function (startRegex, endRegex) {
var chunkObj = this;
var regex;
Function setInputAreaSelectionStartEnd
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
this.setInputAreaSelectionStartEnd = function () {
if (!panels.ieCachedRange && (inputArea.selectionStart || inputArea.selectionStart === 0)) {
stateObj.start = inputArea.selectionStart;
Method init
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.init
ActiveSupport::Notifications.subscribe 'process_action.action_controller' do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
controller = event.payload[:controller]
action = event.payload[:action]
Function init
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
init: function (opts) {
var districtSelect, representativeSelect, representatives, selectedRepresentatives;
districtSelect = opts.districtSelect;
representativeSelect = opts.representativeSelect;
Function handleCtrlYZ
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var handleCtrlYZ = function (event) {
var handled = false;
if ((event.ctrlKey || event.metaKey) && !event.altKey) {
Function ProgramNode
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
ProgramNode: function(statements, inverseStrip, inverse, locInfo) {
var inverseLocationInfo, firstInverseNode;
if (arguments.length === 3) {
locInfo = inverse;
inverse = null;
Function __module0__
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
var __module0__ = (function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__) {
"use strict";
var __exports__;
/*globals Handlebars: true */
var Handlebars = __dependency1__;
Function writeImageTag
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
function writeImageTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
var whole_match = m1;
var alt_text = m2;
var link_id = m3.toLowerCase();
var url = m4;
Function getPageSize
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
position.getPageSize = function () {
var scrollWidth, scrollHeight;
var innerWidth, innerHeight;
Method autocomplete
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def autocomplete
response = Hdo::Search::Searcher.new(params[:query]).autocomplete
@results = []
representative_icon = view_context.asset_path("representative.png")
Method fetch_proposition_counts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch_proposition_counts
labels = []
data = []
result = {labels: labels, data: data}
Method update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
update_issues || return
if @proposition.update_attributes(normalize_blanks(params[:proposition]))
update_proposers
- 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 expand
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def expand(existing, membership)
updates = {}
if membership.start_date < existing.start_date
updates[:start_date] = membership.start_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"