Showing 1,982 of 1,982 total issues

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

  checkPath(path: NodePath, opts?: Object): boolean {
    const { node, parent } = path;
    if (!t.isIdentifier(node, opts) && !t.isJSXMemberExpression(parent, opts)) {
      if (t.isJSXIdentifier(node, opts)) {
        if (react.isCompatTag(node.name)) return false;
Severity: Minor
Found in packages/babel-traverse/src/path/lib/virtual-types.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 evaluateQuasis has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function evaluateQuasis(path, quasis: Array<Object>, state, raw = false) {
  let str = "";

  let i = 0;
  const exprs = path.get("expressions");
Severity: Minor
Found in packages/babel-traverse/src/path/evaluation.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 traverse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export default function traverse(
  parent: Object | Array<Object>,
  opts?: Object,
  scope?: Object,
  state: Object,
Severity: Minor
Found in packages/babel-traverse/src/index.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 save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function save() {
  if (isCacheDisabled()) return;
  let serialised: string = "{}";

  try {
Severity: Minor
Found in packages/babel-register/src/cache.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 (this.getAttachmentParentForPath(violationPath).key > path.key) {
              path = violationPath;
            }
Severity: Major
Found in packages/babel-traverse/src/path/lib/hoister.js - About 45 mins to fix

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

    function getTypeAnnotationBindingConstantViolations(binding, path, name) {
      const types = [];
    
      const functionConstantViolations = [];
      let constantViolations = getConstantViolationsBefore(
    Severity: Minor
    Found in packages/babel-traverse/src/path/inference/inferer-reference.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 BinaryExpression has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export function BinaryExpression(node) {
      const operator = node.operator;
    
      if (t.NUMBER_BINARY_OPERATORS.indexOf(operator) >= 0) {
        return t.numberTypeAnnotation();
    Severity: Minor
    Found in packages/babel-traverse/src/path/inference/inferers.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 (isNamespace) {
              builder.var(name || importedSource).wildcardInterop();
            } else if ((isDefault || isNamed) && ensureLiveReference) {
              if (isDefault) {
                name = name !== "default" ? name : importedSource;
    Severity: Major
    Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

            if (isModuleForNode) {
              // import namespace from ''; namespace
              // import def from ''; def;
              // import namespace from ''; namespace.named
              builder.import();
      Severity: Major
      Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

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

          run() {
            const block = this.block;
            if (DONE.has(block)) return;
            DONE.add(block);
        
        
        Severity: Minor
        Found in packages/babel-plugin-transform-block-scoping/src/index.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 (isNamespace) {
                  builder.namespace(name || importedSource);
                } else if (isDefault || isNamed) {
                  builder.named(name, importName);
                }
        Severity: Major
        Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                if (isDefault && ensureLiveReference) {
                  throw new Error("No live reference for commonjs default");
                }
          Severity: Major
          Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                      if (ensureLiveReference) {
                        builder
                          .default(es6Default)
                          .var(name || importedSource)
                          .defaultInterop()
            Severity: Major
            Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if (isNamed) {
                        builder.default(es6Default).read(importName);
                      }
              Severity: Major
              Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                        if (isNamespace) {
                          builder.default(name || importedSource);
                        } else if (isDefault || isNamed) {
                          builder.default(importedSource).read(name);
                        }
                Severity: Major
                Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                        } else if (isModuleForBabel) {
                          // import * as namespace from ''; namespace
                          // import def from ''; def
                          // import { named } from ''; named
                          // Note: These lookups will break if the module has no __esModule set,
                  Severity: Major
                  Found in packages/babel-helper-module-imports/src/import-injector.js - About 45 mins to fix

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

                    exports.getLowestImplementedVersion = (
                      { features },
                      env,
                      exclude = () => false
                    ) => {
                    Severity: Minor
                    Found in packages/babel-compat-data/scripts/utils-build-data.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 enter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      enter(path, state) {
                        if (path.isAssignmentExpression() || path.isUpdateExpression()) {
                          for (const name of Object.keys(path.getBindingIdentifiers())) {
                            if (
                              state.outsideReferences[name] !==
                    Severity: Minor
                    Found in packages/babel-plugin-transform-block-scoping/src/index.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 (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
                                  if (!this.loopLabel) {
                                    this.loopLabel = this.scope.generateUidIdentifier("loop");
                                  }
                                  caseConsequent.label = t.cloneNode(this.loopLabel);
                    Severity: Major
                    Found in packages/babel-plugin-transform-block-scoping/src/index.js - About 45 mins to fix

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

                        if (extendz) {
                          this.space();
                          this.word("extends");
                          this.space();
                          this.printList(extendz, node);
                      Severity: Major
                      Found in packages/babel-generator/src/generators/typescript.js and 2 other locations - About 45 mins to fix
                      packages/babel-generator/src/generators/typescript.js on lines 88..93
                      packages/babel-generator/src/generators/typescript.js on lines 447..452

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language