Showing 1,982 of 1,982 total issues

Function ExportDeclaration has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

function ExportDeclaration(node: Object) {
  if (node.declaration) {
    const declar = node.declaration;
    this.print(declar, node);
    if (!t.isStatement(declar)) this.semicolon();
Severity: Minor
Found in packages/babel-generator/src/generators/modules.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

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

export function isRegexLiteral(node: ?Object, opts?: Object): boolean {
  console.trace("The node type RegexLiteral has been renamed to RegExpLiteral");
  if (!node) return false;

  const nodeType = node.type;
Severity: Major
Found in packages/babel-types/src/validators/generated/index.js and 3 other locations - About 3 hrs to fix
packages/babel-types/src/validators/generated/index.js on lines 4658..4674
packages/babel-types/src/validators/generated/index.js on lines 4690..4704
packages/babel-types/src/validators/generated/index.js on lines 4705..4721

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

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 4 locations. Consider refactoring.
Open

export function isSpreadProperty(node: ?Object, opts?: Object): boolean {
  console.trace(
    "The node type SpreadProperty has been renamed to SpreadElement",
  );
  if (!node) return false;
Severity: Major
Found in packages/babel-types/src/validators/generated/index.js and 3 other locations - About 3 hrs to fix
packages/babel-types/src/validators/generated/index.js on lines 4658..4674
packages/babel-types/src/validators/generated/index.js on lines 4675..4689
packages/babel-types/src/validators/generated/index.js on lines 4690..4704

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

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 4 locations. Consider refactoring.
Open

export function isRestProperty(node: ?Object, opts?: Object): boolean {
  console.trace("The node type RestProperty has been renamed to RestElement");
  if (!node) return false;

  const nodeType = node.type;
Severity: Major
Found in packages/babel-types/src/validators/generated/index.js and 3 other locations - About 3 hrs to fix
packages/babel-types/src/validators/generated/index.js on lines 4658..4674
packages/babel-types/src/validators/generated/index.js on lines 4675..4689
packages/babel-types/src/validators/generated/index.js on lines 4705..4721

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

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 4 locations. Consider refactoring.
Open

export function isNumberLiteral(node: ?Object, opts?: Object): boolean {
  console.trace(
    "The node type NumberLiteral has been renamed to NumericLiteral",
  );
  if (!node) return false;
Severity: Major
Found in packages/babel-types/src/validators/generated/index.js and 3 other locations - About 3 hrs to fix
packages/babel-types/src/validators/generated/index.js on lines 4675..4689
packages/babel-types/src/validators/generated/index.js on lines 4690..4704
packages/babel-types/src/validators/generated/index.js on lines 4705..4721

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

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

Function verifyConstructor has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function verifyConstructor() {
    if (!classState.isDerived) return;

    const path = classState.userConstructorPath;
    const body = path.get("body");
Severity: Major
Found in packages/babel-plugin-transform-classes/src/transformClass.js - About 3 hrs to fix

    Function readEscapedChar has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      readEscapedChar(inTemplate: boolean): string | null {
        const throwOnInvalid = !inTemplate;
        const ch = this.input.charCodeAt(++this.state.pos);
        ++this.state.pos;
        switch (ch) {
    Severity: Minor
    Found in packages/babel-parser/src/tokenizer/index.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 parseMaybeAssign has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      parseMaybeAssign(
        noIn?: ?boolean,
        refExpressionErrors?: ?ExpressionErrors,
        afterLeftParse?: Function,
        refNeedsArrowPos?: ?Pos,
    Severity: Minor
    Found in packages/babel-parser/src/parser/expression.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 validate has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      validate(parent, key, node) {
        if (!process.env.BABEL_TYPES_8_BREAKING) return;
    
        const match = /\.(\w+)$/.exec(key);
        if (!match) return;
    Severity: Minor
    Found in packages/babel-types/src/definitions/core.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 parseArgv has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function parseArgv(args: Array<string>): CmdOptions | null {
      //
      commander.parse(args);
    
      const errors = [];
    Severity: Minor
    Found in packages/babel-cli/src/babel/options.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 getAttachmentPath has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

      getAttachmentPath() {
        let path = this._getAttachmentPath();
        if (!path) return;
    
        let targetScope = path.scope;
    Severity: Minor
    Found in packages/babel-traverse/src/path/lib/hoister.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 exit has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            exit(path) {
              if (!isModule(path)) return;
    
              const browserGlobals = globals || {};
    
    
    Severity: Major
    Found in packages/babel-plugin-transform-modules-umd/src/index.js - About 3 hrs to fix

      Function flowEnumMembers has 84 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          flowEnumMembers({
            enumName,
            explicitType,
          }: {
            enumName: string,
      Severity: Major
      Found in packages/babel-parser/src/plugins/flow.js - About 3 hrs to fix

        Consider simplifying this complex logical expression.
        Open

          if (
            nodeType === "FlowDeclaration" ||
            "DeclareClass" === nodeType ||
            "DeclareFunction" === nodeType ||
            "DeclareInterface" === nodeType ||
        Severity: Critical
        Found in packages/babel-types/src/validators/generated/index.js - About 3 hrs to fix

          File index.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          //@flow
          
          import { SemVer } from "semver";
          import { logPluginOrPolyfill } from "./debug";
          import getOptionSpecificExcludesFor from "./get-option-specific-excludes";
          Severity: Minor
          Found in packages/babel-preset-env/src/index.js - About 3 hrs to fix

            Function convertToken has 82 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function convertToken(token, source) {
              const type = token.type;
              token.range = [token.start, token.end];
            
              if (type === tt.name) {
            Severity: Major
            Found in eslint/babel-eslint-parser/src/convert/convertTokens.js - About 3 hrs to fix

              Function buildRootChain has 82 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function* buildRootChain(
                opts: ValidatedOptions,
                context: ConfigContext,
              ): Handler<RootConfigChain | null> {
                const programmaticChain = yield* loadProgrammaticChain(
              Severity: Major
              Found in packages/babel-core/src/config/config-chain.js - About 3 hrs to fix

                Function convertFunctionRest has 82 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export default function convertFunctionRest(path) {
                  const { node, scope } = path;
                  if (!hasRest(node)) return false;
                
                  let rest = node.params.pop().argument;
                Severity: Major
                Found in packages/babel-plugin-transform-parameters/src/rest.js - About 3 hrs to fix

                  Function readWord1 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                    readWord1(): string {
                      let word = "";
                      this.state.containsEsc = false;
                      const start = this.state.pos;
                      let chunkStart = this.state.pos;
                  Severity: Minor
                  Found in packages/babel-parser/src/tokenizer/index.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 readRegexp has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                    readRegexp(): void {
                      const start = this.state.pos;
                      let escaped, inClass;
                      for (;;) {
                        if (this.state.pos >= this.length) {
                  Severity: Minor
                  Found in packages/babel-parser/src/tokenizer/index.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

                  Severity
                  Category
                  Status
                  Source
                  Language