src/cursor.js

Summary

Maintainability
F
5 days
Test Coverage

exports has 64 functions (exceeds 20 allowed). Consider refactoring.
Open

module.exports = class Cursor extends Model {
  // Instantiated by a {TextEditor}
  constructor(params) {
    super(params);
    this.editor = params.editor;
Severity: Major
Found in src/cursor.js - About 1 day to fix

    File cursor.js has 497 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const { Point, Range } = require('text-buffer');
    const { Emitter } = require('event-kit');
    const _ = require('underscore-plus');
    const Model = require('./model');
    
    
    Severity: Minor
    Found in src/cursor.js - About 7 hrs to fix

      Function moveToFirstCharacterOfLine has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        moveToFirstCharacterOfLine() {
          let targetBufferColumn;
          const screenRow = this.getScreenRow();
          const screenLineStart = this.editor.clipScreenPosition([screenRow, 0], {
            skipSoftWrapIndentation: true
      Severity: Minor
      Found in src/cursor.js - About 1 hr to fix

        Function getPreviousWordBoundaryBufferPosition has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          getPreviousWordBoundaryBufferPosition(options = {}) {
            const currentBufferPosition = this.getBufferPosition();
            const previousNonBlankRow = this.editor.buffer.previousNonBlankRow(
              currentBufferPosition.row
            );
        Severity: Minor
        Found in src/cursor.js - About 1 hr to fix

          Function getEndOfCurrentWordBufferPosition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            getEndOfCurrentWordBufferPosition(options = {}) {
              const allowNext = options.allowNext !== false;
              const position = this.getBufferPosition();
          
              const scanRange = allowNext
          Severity: Minor
          Found in src/cursor.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

          Function getPreviousWordBoundaryBufferPosition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            getPreviousWordBoundaryBufferPosition(options = {}) {
              const currentBufferPosition = this.getBufferPosition();
              const previousNonBlankRow = this.editor.buffer.previousNonBlankRow(
                currentBufferPosition.row
              );
          Severity: Minor
          Found in src/cursor.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

          Function getBeginningOfCurrentWordBufferPosition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            getBeginningOfCurrentWordBufferPosition(options = {}) {
              const allowPrevious = options.allowPrevious !== false;
              const position = this.getBufferPosition();
          
              const scanRange = allowPrevious
          Severity: Minor
          Found in src/cursor.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 getNextWordBoundaryBufferPosition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            getNextWordBoundaryBufferPosition(options = {}) {
              const currentBufferPosition = this.getBufferPosition();
              const scanRange = Range(
                currentBufferPosition,
                this.editor.getEofBufferPosition()
          Severity: Minor
          Found in src/cursor.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

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

            moveUp(rowCount = 1, { moveToEndOfSelection } = {}) {
              let row, column;
              const range = this.marker.getScreenRange();
              if (moveToEndOfSelection && !range.isEmpty()) {
                ({ row, column } = range.start);
          Severity: Major
          Found in src/cursor.js and 1 other location - About 6 hrs to fix
          src/cursor.js on lines 276..291

          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 168.

          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

            moveDown(rowCount = 1, { moveToEndOfSelection } = {}) {
              let row, column;
              const range = this.marker.getScreenRange();
              if (moveToEndOfSelection && !range.isEmpty()) {
                ({ row, column } = range.end);
          Severity: Major
          Found in src/cursor.js and 1 other location - About 6 hrs to fix
          src/cursor.js on lines 253..268

          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 168.

          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

              this.editor.backwardsScanInBufferRange(
                EmptyLineRegExp,
                scanRange,
                ({ range, stop }) => {
                  position = range.start.traverse(Point(1, 0));
          Severity: Major
          Found in src/cursor.js and 1 other location - About 2 hrs to fix
          src/cursor.js on lines 806..813

          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 78.

          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

              this.editor.scanInBufferRange(
                EmptyLineRegExp,
                scanRange,
                ({ range, stop }) => {
                  position = range.start.traverse(Point(1, 0));
          Severity: Major
          Found in src/cursor.js and 1 other location - About 2 hrs to fix
          src/cursor.js on lines 823..830

          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 78.

          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 (range.start.row > currentBufferPosition.row) {
                  return Point(range.start.row, 0);
                } else if (currentBufferPosition.isLessThan(range.start)) {
                  return Point.fromObject(range.start);
                } else {
          Severity: Minor
          Found in src/cursor.js and 1 other location - About 55 mins to fix
          src/cursor.js on lines 514..523

          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

                if (
                  range.start.row < currentBufferPosition.row &&
                  currentBufferPosition.column > 0
                ) {
                  return Point(currentBufferPosition.row, 0);
          Severity: Minor
          Found in src/cursor.js and 1 other location - About 55 mins to fix
          src/cursor.js on lines 548..554

          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

              } else {
                segments.push(`_*${snakeCamelSegment}`);
                segments.push(`\\s*[${_.escapeRegExp(nonWordCharacters)}]+`);
              }
          Severity: Minor
          Found in src/cursor.js and 1 other location - About 50 mins to fix
          src/cursor.js on lines 758..761

          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 51.

          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 (options.backwards) {
                segments.push(`${snakeCamelSegment}_*`);
                segments.push(`[${_.escapeRegExp(nonWordCharacters)}]+\\s*`);
              } else {
          Severity: Minor
          Found in src/cursor.js and 1 other location - About 50 mins to fix
          src/cursor.js on lines 761..764

          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 51.

          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