tunnckoCore/koa-better-body

View on GitHub

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)
Severity: Major
Found in presets/dev/src/configs/build/index.js and 1 other location - About 2 days to fix
presets/dev/src/configs/bundle/index.js on lines 6..50

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

Further Reading

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)
Severity: Major
Found in presets/dev/src/configs/bundle/index.js and 1 other location - About 2 days to fix
presets/dev/src/configs/build/index.js on lines 6..50

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

Further Reading

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';
Severity: Minor
Found in modules/yaro/src/index.js - About 7 hrs to fix

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',
    );
Severity: Minor
Found in modules/yaro/src/index.js - About 3 hrs 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 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 =
Severity: Minor
Found in packages/eslint/src/api.js - About 2 hrs 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

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
Severity: Minor
Found in modules/yaro/src/index.js - About 2 hrs to fix

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)
Severity: Major
Found in packages/eslint/src/index.js - About 2 hrs to fix

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',
    );
Severity: Major
Found in modules/yaro/src/index.js - About 2 hrs to fix

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)
Severity: Major
Found in presets/dev/src/utils.js - About 2 hrs to fix

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 =
Severity: Major
Found in packages/eslint/src/api.js - About 2 hrs to fix

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 */

Severity: Minor
Found in packages/eslint/src/api.js - About 2 hrs to fix

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]) => {
Severity: Minor
Found in modules/yaro/src/index.js - About 1 hr to fix

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(() => {});
Severity: Minor
Found in modules/yaro/src/index.js - About 1 hr to fix

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)
Severity: Minor
Found in presets/dev/src/configs/bundle/index.js - About 1 hr to fix

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);
Severity: Minor
Found in presets/dev/src/utils.js - About 1 hr to fix

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);
Severity: Minor
Found in modules/cli/src/index.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 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)
Severity: Minor
Found in presets/dev/src/configs/lint/index.js - About 1 hr to fix

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)
Severity: Minor
Found in presets/dev/src/configs/build/index.js - About 1 hr to fix

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

function injectIntoLinter(config, linter) {
  if (!config) {
    return linter;
  }

Severity: Minor
Found in packages/eslint/src/api.js - About 1 hr to fix

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

  createFlag(rawName, description, config) {
    const flag = {
      rawName,
      description,
    };
Severity: Minor
Found in modules/yaro/src/index.js - About 1 hr to fix
Severity
Category
Status
Source
Language