File tree-sitter-language-mode.js
has 1309 lines of code (exceeds 250 allowed). Consider refactoring. Open
const Parser = require('tree-sitter');
const { Point, Range, spliceArray } = require('text-buffer');
const { Patch } = require('superstring');
const { Emitter } = require('event-kit');
const ScopeDescriptor = require('./scope-descriptor');
Function getFoldableRangeForNode
has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring. Open
getFoldableRangeForNode(node, grammar, existenceOnly) {
const { children } = node;
const childCount = children.length;
for (var i = 0, { length } = grammar.folds; i < length; 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
Function getFoldableRangesAtIndentLevel
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
getFoldableRangesAtIndentLevel(goalLevel) {
let result = [];
let stack = [{ node: this.tree.rootNode, level: 0 }];
while (stack.length > 0) {
const { node, level } = stack.pop();
- 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 _populateInjections
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
_populateInjections(range, nodeRangeSet) {
const existingInjectionMarkers = this.languageMode.injectionsMarkerLayer
.findMarkers({ intersectsRange: range })
.filter(marker => marker.parentLanguageLayer === this);
- 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
TreeSitterLanguageMode
has 38 functions (exceeds 20 allowed). Consider refactoring. Open
class TreeSitterLanguageMode {
static _patchSyntaxNode() {
if (!Parser.SyntaxNode.prototype.hasOwnProperty('range')) {
Object.defineProperty(Parser.SyntaxNode.prototype, 'range', {
get() {
Function _populateInjections
has 90 lines of code (exceeds 25 allowed). Consider refactoring. Open
_populateInjections(range, nodeRangeSet) {
const existingInjectionMarkers = this.languageMode.injectionsMarkerLayer
.findMarkers({ intersectsRange: range })
.filter(marker => marker.parentLanguageLayer === this);
Function _performUpdate
has 83 lines of code (exceeds 25 allowed). Consider refactoring. Open
async _performUpdate(nodeRangeSet, params) {
let includedRanges = null;
if (nodeRangeSet) {
includedRanges = nodeRangeSet.getRanges(this.languageMode.buffer);
if (includedRanges.length === 0) {
Function applyLeafRules
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
const applyLeafRules = (rules, cursor) => {
if (!rules || typeof rules === 'string') return rules;
if (Array.isArray(rules)) {
for (let i = 0, { length } = rules; i !== length; ++i) {
const result = applyLeafRules(rules[i], cursor);
- 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 _performUpdate
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
async _performUpdate(nodeRangeSet, params) {
let includedRanges = null;
if (nodeRangeSet) {
includedRanges = nodeRangeSet.getRanges(this.languageMode.buffer);
if (includedRanges.length === 0) {
- 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 getFoldableRangeForNode
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFoldableRangeForNode(node, grammar, existenceOnly) {
const { children } = node;
const childCount = children.length;
for (var i = 0, { length } = grammar.folds; i < length; i++) {
Function seek
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
seek(targetIndex, containingTags, containingTagStartIndices) {
while (this.treeCursor.gotoParent()) {}
this.atEnd = true;
this.closeTags.length = 0;
- 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 moveToSuccessor
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
moveToSuccessor() {
this.closeTags.length = 0;
this.openTags.length = 0;
while (!this.closeTags.length && !this.openTags.length) {
- 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 getFoldableRangesAtIndentLevel
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
getFoldableRangesAtIndentLevel(goalLevel) {
let result = [];
let stack = [{ node: this.tree.rootNode, level: 0 }];
while (stack.length > 0) {
const { node, level } = stack.pop();
Function seek
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
seek(targetIndex, containingTags, containingTagStartIndices) {
while (this.treeCursor.gotoParent()) {}
this.atEnd = true;
this.closeTags.length = 0;
Function tokenizedLineForRow
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
tokenizedLineForRow(row) {
const lineText = this.buffer.lineForRow(row);
const tokens = [];
const iterator = this.buildHighlightIterator();
Function getRanges
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
getRanges(buffer) {
const previousRanges = this.previous && this.previous.getRanges(buffer);
const result = [];
for (const node of this.nodes) {
- 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 handleTextChange
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
handleTextChange(edit, oldText, newText) {
const { startPosition, oldEndPosition, newEndPosition } = edit;
if (this.tree) {
this.tree.edit(edit);
- 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 tokenizedLineForRow
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
tokenizedLineForRow(row) {
const lineText = this.buffer.lineForRow(row);
const tokens = [];
const iterator = this.buildHighlightIterator();
- 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 parseCompletePromise
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async parseCompletePromise() {
let done = false;
while (!done) {
if (this.rootLanguageLayer.currentParsePromise) {
await this.rootLanguageLayer.currentParsePromises;
- 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 getRanges
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
getRanges(buffer) {
const previousRanges = this.previous && this.previous.getRanges(buffer);
const result = [];
for (const node of this.nodes) {
Function _pushRange
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_pushRange(buffer, previousRanges, newRanges, newRange) {
if (!previousRanges) {
if (this.newlinesBetween) {
const { startIndex, startPosition } = newRange;
this._ensureNewline(buffer, newRanges, startIndex, startPosition);
Function logState
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
logState() {
const iterator = last(this.iterators);
if (iterator && iterator.treeCursor) {
console.log(
iterator.getPosition(),
Function _pushRange
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_pushRange(buffer, previousRanges, newRanges, newRange) {
if (!previousRanges) {
if (this.newlinesBetween) {
const { startIndex, startPosition } = newRange;
this._ensureNewline(buffer, newRanges, startIndex, startPosition);
- 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 moveToSuccessor
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
moveToSuccessor() {
this.closeTags.length = 0;
this.openTags.length = 0;
while (!this.closeTags.length && !this.openTags.length) {
Function handleTextChange
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
handleTextChange(edit, oldText, newText) {
const { startPosition, oldEndPosition, newEndPosition } = edit;
if (this.tree) {
this.tree.edit(edit);
Function seek
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
seek(targetPosition, endRow) {
const injectionMarkers = this.languageMode.injectionsMarkerLayer.findMarkers(
{
intersectsRange: new Range(targetPosition, new Point(endRow + 1, 0))
}
Avoid deeply nested control flow statements. Open
if (
result[i].start.row === range.start.row &&
result[i].end.row === range.end.row
) {
result[i] = range;
Avoid deeply nested control flow statements. Open
if (existingMarker.languageLayer.grammar === grammar) {
marker = existingMarker;
break;
}
Function update
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
async update(nodeRangeSet) {
if (!this.currentParsePromise) {
while (
!this.destroyed &&
(!this.tree || this.tree.rootNode.hasChanges())
- 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
Avoid deeply nested control flow statements. Open
if (childLevel <= goalLevel || goalLevel == null) {
stack.push({ node: child, level: childLevel });
}
Function moveToSuccessor
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
moveToSuccessor() {
// Advance the earliest layer iterator to its next scope boundary.
let leader = last(this.iterators);
// Maintain the sorting of the iterators by their position in the document.
- 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 scopeDescriptorForPosition
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
scopeDescriptorForPosition(point) {
point = this.buffer.clipPosition(Point.fromObject(point));
// If the position is the end of a line, get scope of left character instead of newline
// This is to match TextMate behaviour, see https://github.com/atom/atom/issues/18463
- 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
Avoid too many return
statements within this function. Open
return rules.match.test(cursor.nodeText)
? applyLeafRules(rules.scopes, cursor)
: undefined;
Function _moveDown
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_moveDown() {
let result = false;
const { startIndex } = this.treeCursor;
// Once the iterator has found a scope boundary, it needs to stay at the same
- 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 2 locations. Consider refactoring. Open
indentLevelForLine(line, tabLength) {
let indentLength = 0;
for (let i = 0, { length } = line; i < length; i++) {
const char = line[i];
if (char === '\t') {
- 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 111.
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
if (
point.column > 0 &&
point.column === this.buffer.lineLengthForRow(point.row)
) {
point = point.copy();
- 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 69.
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
if (
point.column > 0 &&
point.column === this.buffer.lineLengthForRow(point.row)
) {
point = point.copy();
- 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 69.
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
constructor(previous, nodes, newlinesBetween, includeChildren) {
this.previous = previous;
this.nodes = nodes;
this.newlinesBetween = newlinesBetween;
this.includeChildren = includeChildren;
- 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
getOpenScopeIds() {
const iterator = last(this.iterators);
if (iterator && !this.currentScopeIsCovered) {
return iterator.getOpenScopeIds();
}
- 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 54.
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
getCloseScopeIds() {
const iterator = last(this.iterators);
if (iterator && !this.currentScopeIsCovered) {
return iterator.getCloseScopeIds();
}
- 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 54.
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
next.offset === first.offset &&
next.atEnd === first.atEnd &&
next.depth > first.depth &&
!next.isAtInjectionBoundary()
- 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 46.
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