tunnckoCore/koa-better-body

View on GitHub

Showing 30 of 38 total issues

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

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 createJestCommand has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

exports.createJestCommand = function createJestCommand(prog) {
  return (name, description, settings = {}) =>
    (prog || hela())
      .command(name, description)
      .alias(settings.alias)
Severity: Minor
Found in presets/dev/src/utils.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 checkHelp has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  checkHelp(cmd) {
    if (this.result.flags.help) {
      const name = cmd && cmd.command && cmd.command.commandName;

      this.showHelp(this.settings.defaultCommand ? '' : name);
Severity: Minor
Found in modules/yaro/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

Severity
Category
Status
Source
Language