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;
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);
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);
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) !== '') {
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')) {
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')) {
- 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 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' },
) {
- 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 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);
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,
Function construct
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
static construct({
hasNamedExports,
isType = false,
makeRelativeTo,
relativeFilePath,
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 = {};
Function findJsModulesFromModuleFinder
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
config: Configuration,
normalizedName: string,
variableName: string,
finder: ModuleFinder,
pathToCurrentFile: string,
Identical blocks of code found in 2 locations. Consider refactoring. Open
const { equals, value } = equalsAndValue({
declarationKeyword: this.declarationKeyword,
importFunction: this.importFunction,
path: this.path,
});
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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) {
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
const { equals, value } = equalsAndValue({
declarationKeyword: this.declarationKeyword,
importFunction: this.importFunction,
path: this.path,
});
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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' &&
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (item) {
this.db.run(
'UPDATE mtimes SET mtime = ? WHERE (path = ?)',
mtime,
pathToFile,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} else {
this.db.run(
'INSERT INTO mtimes (mtime, path) VALUES (?, ?)',
mtime,
pathToFile,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
types.map((name) =>
this._insert({
name,
pathToFile,
isDefault: false,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
const promises = names.map((name) =>
this._insert({
name,
pathToFile,
isDefault: false,
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76