Galooshi/import-js

View on GitHub

Showing 95 of 95 total issues

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

  constructor(
    pathToCurrentFile: string,
    workingDirectory: string = process.cwd(),
  ) {
    this.workingDirectory = workingDirectory;
Severity: Minor
Found in lib/Configuration.js - About 1 hr to fix

    Function defaultExportNames has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function defaultExportNames(pathToFile) {
      const parsed = path.parse(pathToFile);
      let fileName = parsed.name;
      let dirName = path.basename(parsed.dir);
    
    
    Severity: Minor
    Found in lib/ModuleFinder.js - About 1 hr to fix

      Function validate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function validate(data) {
        const ajv = new Ajv();
        ajvInstanceof(ajv);
      
        const validate = ajv.compile(SCHEMA);
      Severity: Minor
      Found in lib/configurationSchema.js - About 1 hr to fix

        Function replaceImports has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          replaceImports(oldImportsRange: Object, newImports: ImportStatements) {
            const importStrings = newImports.toArray();
        
            // Ensure that there is a blank line after the block of all imports
            if (importStrings.length && this.editor.get(oldImportsRange.end) !== '') {
        Severity: Minor
        Found in lib/Importer.js - About 1 hr to fix

          Function resolveForPackage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function resolveForPackage(
            filePath: string,
            workingDirectory: string,
          ): ?Array<?string> {
            if (!filePath.endsWith('/package.json')) {
          Severity: Minor
          Found in lib/resolveImportPathAndMain.js - About 1 hr to fix

            Function resolveForPackage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            function resolveForPackage(
              filePath: string,
              workingDirectory: string,
            ): ?Array<?string> {
              if (!filePath.endsWith('/package.json')) {
            Severity: Minor
            Found in lib/resolveImportPathAndMain.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 visitIdentifierNodes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

            export default function visitIdentifierNodes(
              rootAstNode,
              visitor,
              context = { definedInScope: new Set([]), key: 'root' },
            ) {
            Severity: Minor
            Found in lib/visitIdentifierNodes.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 resolveNestedNamedExports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function resolveNestedNamedExports(node, absolutePathToFile) {
              if (node.type === 'ConditionalExpression') {
                // Potential ternary-style export - we pick the first one
                // module.exports = foo ? require('a') : require('b');
                return resolveNestedNamedExports(node.consequent, absolutePathToFile);
            Severity: Minor
            Found in lib/findExports.js - About 1 hr to fix

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

                _remove(pattern, operator = '=') {
                  return new Promise((resolve, reject) => {
                    this.db.run(
                      `DELETE FROM exports WHERE (path ${operator} ?)`,
                      pattern,
              Severity: Minor
              Found in lib/ExportsStorage.js - About 1 hr to fix

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

                  static construct({
                    hasNamedExports,
                    isType = false,
                    makeRelativeTo,
                    relativeFilePath,
                Severity: Minor
                Found in lib/JsModule.js - About 1 hr to fix

                  Function poll has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    poll(): Promise<void> {
                      return new Promise((resolve: Function, reject: Function) => {
                        findAllFiles(this.workingDirectory, this.excludes)
                          .then((files: Array<Object>) => {
                            const mtimes = {};
                  Severity: Minor
                  Found in lib/Watcher.js - About 1 hr to fix

                    Function findJsModulesFromModuleFinder has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      config: Configuration,
                      normalizedName: string,
                      variableName: string,
                      finder: ModuleFinder,
                      pathToCurrentFile: string,
                    Severity: Minor
                    Found in lib/findJsModulesFor.js - About 45 mins to fix

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

                          const { equals, value } = equalsAndValue({
                            declarationKeyword: this.declarationKeyword,
                            importFunction: this.importFunction,
                            path: this.path,
                          });
                      Severity: Minor
                      Found in lib/ImportStatement.js and 1 other location - About 45 mins to fix
                      lib/ImportStatement.js on lines 292..296

                      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

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

                      function findDefinedNames(node, definedNames) {
                        if (node.type === 'ExpressionStatement') {
                          const { left, right } = node.expression;
                          if (left && right) {
                            if (left.object) {
                      Severity: Minor
                      Found in lib/findExports.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

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

                          const { equals, value } = equalsAndValue({
                            declarationKeyword: this.declarationKeyword,
                            importFunction: this.importFunction,
                            path: this.path,
                          });
                      Severity: Minor
                      Found in lib/ImportStatement.js and 1 other location - About 45 mins to fix
                      lib/ImportStatement.js on lines 307..311

                      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

                      Consider simplifying this complex logical expression.
                      Open

                        if (
                          node.expression.type === 'CallExpression' &&
                          node.expression.callee.type === 'MemberExpression' &&
                          aliasesForExports.has(node.expression.callee.object.name) &&
                          node.expression.callee.property.name === 'use' &&
                      Severity: Major
                      Found in lib/findExports.js - About 40 mins to fix

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

                                  if (item) {
                                    this.db.run(
                                      'UPDATE mtimes SET mtime = ? WHERE (path = ?)',
                                      mtime,
                                      pathToFile,
                        Severity: Minor
                        Found in lib/ExportsStorage.js and 1 other location - About 40 mins to fix
                        lib/ExportsStorage.js on lines 183..196

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

                        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 {
                                    this.db.run(
                                      'INSERT INTO mtimes (mtime, path) VALUES (?, ?)',
                                      mtime,
                                      pathToFile,
                        Severity: Minor
                        Found in lib/ExportsStorage.js and 1 other location - About 40 mins to fix
                        lib/ExportsStorage.js on lines 170..183

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

                        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

                                  types.map((name) =>
                                    this._insert({
                                      name,
                                      pathToFile,
                                      isDefault: false,
                        Severity: Minor
                        Found in lib/ExportsStorage.js and 1 other location - About 35 mins to fix
                        lib/ExportsStorage.js on lines 260..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 47.

                        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

                                const promises = names.map((name) =>
                                  this._insert({
                                    name,
                                    pathToFile,
                                    isDefault: false,
                        Severity: Minor
                        Found in lib/ExportsStorage.js and 1 other location - About 35 mins to fix
                        lib/ExportsStorage.js on lines 270..278

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

                        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