Showing 328 of 328 total issues
Function parseStatement
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseStatement() {
var type = lookahead.type,
expr,
labeledBody,
key;
Class Endpoint
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class Endpoint
include Lurker::Utils
PREFIX = 'prefix'.freeze
ACTION = 'action'.freeze
Function skipComment
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
function skipComment() {
var ch, blockComment, lineComment;
blockComment = false;
lineComment = false;
Function unpatch
has 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
function unpatch() {
if (typeof extra.skipComment === 'function') {
skipComment = extra.skipComment;
}
Identical blocks of code found in 2 locations. Consider refactoring. Open
} else if (match('[')) {
expr = delegate.createMemberExpression('[', expr, parseComputedMember());
} else if (match('.')) {
expr = delegate.createMemberExpression('.', expr, parseNonComputedMember());
} 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 86.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
if (match('[')) {
expr = delegate.createMemberExpression('[', expr, parseComputedMember());
} else if (match('.')) {
expr = delegate.createMemberExpression('.', expr, parseNonComputedMember());
} 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 86.
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 _renderClassBody
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _renderClassBody(traverse, node, path, state) {
var className = state.className;
var superClass = state.superClass;
// Set up prototype of constructor on same line as `extends` for line-number
Function SourceNode_fromStringWithSourceMap
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) {
// The SourceNode we want to fill with the generated code
// and the SourceMap
var node = new SourceNode();
Function wrapTrackingFunction
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wrapTrackingFunction(range, loc, preserveWhitespace) {
return function (parseFunction) {
function isBinary(node) {
Function SourceNode_toStringWithSourceMap
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
var generated = {
code: "",
line: 1,
column: 0
Function SourceMapConsumer_parseMappings
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
var generatedLine = 1;
var previousGeneratedColumn = 0;
var previousOriginalLine = 0;
var previousOriginalColumn = 0;
Function parseArrayInitialiser
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseArrayInitialiser() {
var elements = [], blocks = [], filter = null, tmp, possiblecomprehension = true, body;
expect('[');
while (!match(']')) {
Consider simplifying this complex logical expression. Open
else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
&& aOriginal && 'line' in aOriginal && 'column' in aOriginal
&& aGenerated.line > 0 && aGenerated.column >= 0
&& aOriginal.line > 0 && aOriginal.column >= 0
&& aSource) {
Function 28
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"./xjs":29,"esprima-fb":6,"jstransform/src/utils":20}],28:[function(_dereq_,module,exports){
/**
* Copyright 2013-2014 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Function traverse
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function traverse(node, path, state) {
// Create a scope stack entry if this is the first node we've encountered in
// its local scope
var parentNode = path[0];
if (!Array.isArray(node) && state.localScope.parentNode !== parentNode) {
Function parsePrimaryExpression
has 58 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parsePrimaryExpression() {
var type, token;
token = lookahead;
type = lookahead.type;
Function 10
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"./util":16,"amdefine":17}],10:[function(_dereq_,module,exports){
/* -*- Mode: js; js-indent-level: 2; -*- */
/*
* Copyright 2011 Mozilla Foundation and contributors
* Licensed under the New BSD license. See LICENSE or:
Method filtering_block
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def filtering_block
if options['select'].present?
select = /#{options['select']}/
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
Function binaryPrecedence
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
function binaryPrecedence(token, allowIn) {
var prec = 0;
if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
return 0;
Function 21
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
},{"./docblock":18}],21:[function(_dereq_,module,exports){
/**
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");