Galooshi/import-js

View on GitHub

Showing 95 of 95 total issues

Function findCurrentImports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function findCurrentImports(
  config: Configuration,
  currentFileContent: string,
  ast: Object,
): Object {
Severity: Minor
Found in lib/findCurrentImports.js - About 1 hr to fix

    Function merge has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      merge(importStatement: ImportStatement) {
        if (
          importStatement.defaultImport &&
          this.defaultImport !== importStatement.defaultImport
        ) {
    Severity: Minor
    Found in lib/ImportStatement.js - About 1 hr to fix

      Function fixImports has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        fixImports(): Promise<Object> {
          const undefinedVariables = findUndefinedIdentifiers(
            this.ast,
            this.config.get('globals'),
          );
      Severity: Minor
      Found in lib/Importer.js - About 1 hr to fix

        Function addImports has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          addImports(imports: Object): Promise<Object> {
            return new Promise((resolve: Function, reject: Function) => {
              const oldImports = this.findCurrentImports();
              const newImports = oldImports.imports.clone();
        
        
        Severity: Minor
        Found in lib/Importer.js - About 1 hr to fix

          Function mergedValue has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function mergedValue(values: Array<any>, key: string, options: Object): any {
            let mergedResult;
            for (let i = 0; i < values.length; i += 1) {
              let value = values[i];
              if (typeof value === 'function') {
          Severity: Minor
          Found in lib/Configuration.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 _insert has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _insert({ name, pathToFile, isDefault, isType, packageName, additional }) {
              const exportName = isDefault ? normalizedExportName(name) : name;
              return Promise.all([
                new Promise((resolve, reject) => {
                  this.db.run(
          Severity: Minor
          Found in lib/ExportsStorage.js - About 1 hr to fix

            Function findJsModulesFor has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function findJsModulesFor(
              config: Configuration,
              variableName: string,
              options?: FindJsModulesForOptionsType,
            ): Promise<Array<JsModule>> {
            Severity: Minor
            Found in lib/findJsModulesFor.js - About 1 hr to fix

              Function _namedImportString has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _namedImportString(maxLineLength: number, tab: string): string {
                  const { equals, value } = equalsAndValue({
                    declarationKeyword: this.declarationKeyword,
                    importFunction: this.importFunction,
                    path: this.path,
              Severity: Minor
              Found in lib/ImportStatement.js - About 1 hr to fix

                Function updateMtime has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  updateMtime(pathToFile, mtime) {
                    return new Promise((resolve, reject) => {
                      this.db.get(
                        'SELECT mtime FROM mtimes WHERE (path = ?)',
                        pathToFile,
                Severity: Minor
                Found in lib/ExportsStorage.js - About 1 hr to fix

                  Function rewriteImports has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    rewriteImports(): Object {
                      const oldImports = this.findCurrentImports();
                      const newImports = new ImportStatements(this.config);
                  
                      return new Promise((resolve: Function, reject: Function) => {
                  Severity: Minor
                  Found in lib/Importer.js - About 1 hr to fix

                    Function expandFiles has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function expandFiles(files, workingDirectory) {
                      const promises = [];
                      files.forEach((file) => {
                        if (
                          file.path !== './package.json' &&
                    Severity: Minor
                    Found in lib/ModuleFinder.js - About 1 hr to fix

                      Function findExports has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export default function findExports(data, absolutePathToFile) {
                        if (/\.json$/.test(absolutePathToFile)) {
                          return {
                            named: Object.keys(JSON.parse(data)),
                            typed: [],
                      Severity: Minor
                      Found in lib/findExports.js - About 1 hr to fix

                        Function update has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          update({
                            names = [],
                            types = [],
                            defaultNames,
                            pathToFile,
                        Severity: Minor
                        Found in lib/ExportsStorage.js - About 1 hr to fix

                          Function _toGroups has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            _toGroups(): Array<Array<ImportStatement>> {
                              const groups = [];
                          
                              const importsArray = Object.keys(this.imports).map(
                                (key: string): ImportStatement => this.imports[key],
                          Severity: Minor
                          Found in lib/ImportStatements.js - About 1 hr to fix

                            Function _namedImportString has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                              _namedImportString(maxLineLength: number, tab: string): string {
                                const { equals, value } = equalsAndValue({
                                  declarationKeyword: this.declarationKeyword,
                                  importFunction: this.importFunction,
                                  path: this.path,
                            Severity: Minor
                            Found in lib/ImportStatement.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 needsUpdate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              needsUpdate(files) {
                                if (files.length > MAX_CHUNK_SIZE) {
                                  // sqlite has a max number for arguments passed. We need to execute in
                                  // chunks if we exceed the max.
                                  const promises = arrayToChunks(files, MAX_CHUNK_SIZE).map((chunk) =>
                            Severity: Minor
                            Found in lib/ExportsStorage.js - About 1 hr to fix

                              Function goto has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                goto(variableName: string): Promise<Object> {
                                  const { imports } = this.findCurrentImports();
                                  const filePath = findFilePathFromImports(
                                    imports,
                                    path.dirname(this.pathToCurrentFile),
                              Severity: Minor
                              Found in lib/Importer.js - About 1 hr to fix

                                Consider simplifying this complex logical expression.
                                Open

                                  if (
                                    node.expression.type === 'CallExpression' &&
                                    node.expression.callee.type === 'MemberExpression' &&
                                    node.expression.callee.object.name === 'Object' &&
                                    node.expression.callee.property.name === 'defineProperty' &&
                                Severity: Critical
                                Found in lib/findExports.js - About 1 hr to fix

                                  Function resolveOneJsModule has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                    resolveOneJsModule(
                                      jsModules: Array<JsModule>,
                                      variableName: string,
                                    ): ?JsModule {
                                      if (jsModules.length === 1) {
                                  Severity: Minor
                                  Found in lib/Importer.js - About 1 hr to fix

                                    Function validate has a Cognitive Complexity of 11 (exceeds 5 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

                                    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