src/tree-sitter-language-mode.js

Summary

Maintainability
F
1 wk
Test Coverage

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');
Severity: Major
Found in src/tree-sitter-language-mode.js - About 3 days to fix

    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++) {
    Severity: Minor
    Found in src/tree-sitter-language-mode.js - About 1 day to fix

    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();
    Severity: Minor
    Found in src/tree-sitter-language-mode.js - About 6 hrs to fix

    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);
    
    
    Severity: Minor
    Found in src/tree-sitter-language-mode.js - About 5 hrs to fix

    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() {
    Severity: Minor
    Found in src/tree-sitter-language-mode.js - About 5 hrs to fix

      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);
      
      
      Severity: Major
      Found in src/tree-sitter-language-mode.js - About 3 hrs to fix

        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) {
        Severity: Major
        Found in src/tree-sitter-language-mode.js - About 3 hrs to fix

          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);
          Severity: Minor
          Found in src/tree-sitter-language-mode.js - About 3 hrs to fix

          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) {
          Severity: Minor
          Found in src/tree-sitter-language-mode.js - About 3 hrs to fix

          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++) {
          Severity: Major
          Found in src/tree-sitter-language-mode.js - About 2 hrs to fix

            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;
            Severity: Minor
            Found in src/tree-sitter-language-mode.js - About 2 hrs to fix

            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) {
            Severity: Minor
            Found in src/tree-sitter-language-mode.js - About 2 hrs to fix

            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();
            Severity: Major
            Found in src/tree-sitter-language-mode.js - About 2 hrs to fix

              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;
              Severity: Minor
              Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                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();
                Severity: Minor
                Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                  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) {
                  Severity: Minor
                  Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                  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);
                  Severity: Minor
                  Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                  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();
                  Severity: Minor
                  Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                  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;
                  Severity: Minor
                  Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                  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) {
                  Severity: Minor
                  Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                    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);
                    Severity: Minor
                    Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                      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(),
                      Severity: Minor
                      Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                        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);
                        Severity: Minor
                        Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                        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) {
                        Severity: Minor
                        Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                          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);
                          Severity: Minor
                          Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                            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))
                                  }
                            Severity: Minor
                            Found in src/tree-sitter-language-mode.js - About 1 hr to fix

                              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;
                              Severity: Major
                              Found in src/tree-sitter-language-mode.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (existingMarker.languageLayer.grammar === grammar) {
                                              marker = existingMarker;
                                              break;
                                            }
                                Severity: Major
                                Found in src/tree-sitter-language-mode.js - About 45 mins to fix

                                  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())
                                  Severity: Minor
                                  Found in src/tree-sitter-language-mode.js - About 45 mins to fix

                                  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 });
                                              }
                                  Severity: Major
                                  Found in src/tree-sitter-language-mode.js - About 45 mins to fix

                                    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.
                                    Severity: Minor
                                    Found in src/tree-sitter-language-mode.js - About 35 mins to fix

                                    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
                                    Severity: Minor
                                    Found in src/tree-sitter-language-mode.js - About 35 mins to fix

                                    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;
                                    Severity: Major
                                    Found in src/tree-sitter-language-mode.js - About 30 mins to fix

                                      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
                                      Severity: Minor
                                      Found in src/tree-sitter-language-mode.js - About 25 mins to fix

                                      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') {
                                      Severity: Major
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 3 hrs to fix
                                      src/text-mate-language-mode.js on lines 589..602

                                      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

                                      Further Reading

                                      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();
                                      Severity: Major
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 1 hr to fix
                                      src/tree-sitter-language-mode.js on lines 556..562

                                      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

                                      Further Reading

                                      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();
                                      Severity: Major
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 1 hr to fix
                                      src/tree-sitter-language-mode.js on lines 590..596

                                      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

                                      Further Reading

                                      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;
                                      Severity: Major
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 1 hr to fix
                                      src/color.js on lines 45..50

                                      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

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                        getOpenScopeIds() {
                                          const iterator = last(this.iterators);
                                          if (iterator && !this.currentScopeIsCovered) {
                                            return iterator.getOpenScopeIds();
                                          }
                                      Severity: Minor
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 55 mins to fix
                                      src/tree-sitter-language-mode.js on lines 1048..1054

                                      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

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                        getCloseScopeIds() {
                                          const iterator = last(this.iterators);
                                          if (iterator && !this.currentScopeIsCovered) {
                                            return iterator.getCloseScopeIds();
                                          }
                                      Severity: Minor
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 55 mins to fix
                                      src/tree-sitter-language-mode.js on lines 1056..1062

                                      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

                                      Further Reading

                                      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()
                                      Severity: Minor
                                      Found in src/tree-sitter-language-mode.js and 1 other location - About 35 mins to fix
                                      src/dock.js on lines 896..899

                                      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

                                      Further Reading

                                      There are no issues that match your filters.

                                      Category
                                      Status