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 {
Function merge
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
merge(importStatement: ImportStatement) {
if (
importStatement.defaultImport &&
this.defaultImport !== importStatement.defaultImport
) {
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'),
);
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();
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') {
- Read upRead up
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(
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>> {
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,
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,
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) => {
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' &&
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: [],
Function update
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
update({
names = [],
types = [],
defaultNames,
pathToFile,
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],
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,
- Read upRead up
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) =>
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),
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' &&
Function resolveOneJsModule
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
resolveOneJsModule(
jsModules: Array<JsModule>,
variableName: string,
): ?JsModule {
if (jsModules.length === 1) {
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);
- Read upRead up
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"