Showing 38 of 38 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
module.exports = function createJestBabelConfig(options) {
const opts = { cwd: process.cwd(), ...options };
const { exts, alias, workspaces } = utils.createAliases(opts.cwd);
const ignores = []
.concat(opts.ignores)
- Read upRead up
- Create a ticketCreate a ticket
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 402.
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
module.exports = function createJestRollupConfig(options) {
const opts = { cwd: process.cwd(), ...options };
const { exts, alias, workspaces } = utils.createAliases(opts.cwd);
const ignores = []
.concat(opts.ignores)
- Read upRead up
- Create a ticketCreate a ticket
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 402.
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
File index.js
has 488 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable no-continue */
/* eslint-disable class-methods-use-this */
/* eslint-disable no-underscore-dangle */
'use strict';
- Create a ticketCreate a ticket
Function buildHelpOutput
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
buildHelpOutput(commandName) {
const sections = [];
const commands = [...this.commands.values()].filter(
(x) => x.commandName !== '$$root',
);
- Read upRead up
- Create a ticketCreate a ticket
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 lintFiles
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
async function* lintFiles(patterns, options) {
const opts = { dirs: [], cwd: process.cwd(), ...options };
opts.exclude = opts.exclude || DEFAULT_IGNORE;
opts.extensions = opts.extensions || DEFAULT_EXTENSIONS;
opts.cacheLocation =
- Read upRead up
- Create a ticketCreate a ticket
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
Yaro
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class Yaro {
constructor(programName, options) {
if (isObject(programName) && !options) {
options = programName; // eslint-disable-line no-param-reassign
programName = null; // eslint-disable-line no-param-reassign
- Create a ticketCreate a ticket
Function wrapper
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
function wrapper(prog) {
return prog
.option('--init', 'Create lint config from fully resolved ESLint config')
.option('--fix', 'Automatically fix problems')
.option('--warnings', 'Shows warnings too', false)
- Create a ticketCreate a ticket
Function buildHelpOutput
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
buildHelpOutput(commandName) {
const sections = [];
const commands = [...this.commands.values()].filter(
(x) => x.commandName !== '$$root',
);
- Create a ticketCreate a ticket
Function createJestCommand
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.createJestCommand = function createJestCommand(prog) {
return (name, description, settings = {}) =>
(prog || hela())
.command(name, description)
.alias(settings.alias)
- Create a ticketCreate a ticket
Function lintFiles
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function* lintFiles(patterns, options) {
const opts = { dirs: [], cwd: process.cwd(), ...options };
opts.exclude = opts.exclude || DEFAULT_IGNORE;
opts.extensions = opts.extensions || DEFAULT_EXTENSIONS;
opts.cacheLocation =
- Create a ticketCreate a ticket
File api.js
has 252 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable global-require */
/* eslint-disable import/no-dynamic-require */
/* eslint-disable no-restricted-syntax */
/* eslint-disable max-statements */
- Create a ticketCreate a ticket
Function __getResult
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
__getResult(argv) {
const flagAliases = {};
[...this.commands.entries()].forEach(([_, cmd]) => {
[...cmd.flags.entries()].forEach(([flagName, flag]) => {
- Create a ticketCreate a ticket
Function parse
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
parse(argv = processArgv, options = {}) {
// NOTE: it's in a single command mode but does not have `.action` defined,
// so we create noop one o uccessfully continue
if (!this.currentCommand && this.settings.singleMode === true) {
this.action(() => {});
- Create a ticketCreate a ticket
Function createJestRollupConfig
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function createJestRollupConfig(options) {
const opts = { cwd: process.cwd(), ...options };
const { exts, alias, workspaces } = utils.createAliases(opts.cwd);
const ignores = []
.concat(opts.ignores)
- Create a ticketCreate a ticket
Function ssss
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
.action(async function ssss(argv) {
// switch the env set by default when running Jest. For ensurance.
process.env.NODE_ENV = name;
// console.log(arguments);
- Create a ticketCreate a ticket
Function tryLoadConfig
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
async function tryLoadConfig(name) {
let mod = null;
try {
mod = require(name);
- Read upRead up
- Create a ticketCreate a ticket
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 createJestESLintConfig
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function createJestESLintConfig(options) {
const opts = { cwd: process.cwd(), ...options };
const { exts, alias, workspaces } = utils.createAliases(opts.cwd);
const ignores = []
.concat(opts.ignores)
- Create a ticketCreate a ticket
Function createJestBabelConfig
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.exports = function createJestBabelConfig(options) {
const opts = { cwd: process.cwd(), ...options };
const { exts, alias, workspaces } = utils.createAliases(opts.cwd);
const ignores = []
.concat(opts.ignores)
- Create a ticketCreate a ticket
Function injectIntoLinter
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
function injectIntoLinter(config, linter) {
if (!config) {
return linter;
}
- Create a ticketCreate a ticket
Function createFlag
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
createFlag(rawName, description, config) {
const flag = {
rawName,
description,
};
- Create a ticketCreate a ticket