Showing 302 of 302 total issues
Method import_proposition
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def import_proposition(xprop, vote = nil)
log_import xprop
xprop.validate!
return if xprop.external_id == "-1" # https://github.com/holderdeord/hdo-site/issues/138
- 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 update
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def update
# 1. all input memberships reflect the current state and should be added
# 2. if one intersects an existing membership in the same committee, we
# adjust it to reflect the new data.
# 3. if an existing, current membership is not present in the new data, it is
- 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 block
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
block: function(block) {
var mustache = block.mustache,
program = block.program,
inverse = block.inverse;
Method result
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def result
@result ||= (
result = Hash.new { |hash, key| hash[key] = {count: 0, total: 0} }
count = 0
Method fetch
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def fetch
payload = {}
payload[:size] = size
payload.merge! facets
Method generate_agreement_for_category
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_agreement_for_category
category_name = ENV['CATEGORY_NAME'] || abort('must set CATEGORY_NAME')
pis_by_session = Category.where(name: category_name).first.parliament_issues.group_by { |pi| pi.parliament_session_name }
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!e.shiftKey){
$next = $next.data('tabindex') < $(this).data('tabindex') ?
$next = $(this) :
$rollover = $(this);
} else {
- 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 56.
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
} else {
$next = $next.data('tabindex') > $(this).data('tabindex') ?
$next = $(this) :
$rollover = $(this);
}
- 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 56.
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 show
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
show: function () {
var that = this,
e = $.Event('show');
if (this.isShown) return;
Function _ProcessListItems
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _ProcessListItems(list_str, list_type) {
//
// Process the contents of a single ordered or unordered list, splitting it
// into individual list items.
//
Function swipeReset
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
_this.swipeReset = function(prevention) {
_this.callPlugins('onSwipeReset');
var getTranslate = isHorizontal ? _this.getTranslate('x') : _this.getTranslate('y');
var newPosition = getTranslate<0 ? Math.round(getTranslate/slideSize)*slideSize : 0
Function IdNode
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
IdNode: function(parts, locInfo) {
LocationInfo.call(this, locInfo);
this.type = "ID";
var original = "",
Function handleTrailingParens
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function handleTrailingParens(wholeMatch, lookbehind, protocol, link) {
if (lookbehind)
return wholeMatch;
if (link.charAt(link.length - 1) !== ")")
return "<" + protocol + link + ">";
Function doClick
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function doClick(button) {
inputBox.focus();
if (button.textOp) {
Method vote
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def vote
@vote = Vote.find(params[:id])
@header = @vote.subject
if params[:proposition]
Function equals
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
equals: function(other) {
var len = this.opcodes.length;
if (other.opcodes.length !== len) {
return false;
}
Method update_index_on_change_of
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update_index_on_change_of(*classes)
if classes.last.kind_of?(Hash)
opts = classes.pop
else
opts = {}
Function writeAnchorTag
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
function writeAnchorTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
Function writeImageTag
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
function writeImageTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
this.timeout = setTimeout(function() {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
- 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 55.
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