tunnckoCore/koa-better-body

View on GitHub
packages/eslint/src/api.js

Summary

Maintainability
C
1 day
Test Coverage

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

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

function lint(options) {
  const opts = { ...options };
  const cfg = { ...opts.config, filename: opts.filename };
  const linter = opts.linter || new Linter();
  const filter = (x) =>
Severity: Minor
Found in packages/eslint/src/api.js - About 55 mins 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

Consider simplifying this complex logical expression.
Open

    if (ctx.changed) {
      const dirname = path.dirname(ctx.file.path);
      if (opts.dirs.includes(dirname)) {
        eslintConfig = await resolveConfig(ctx.file.path, 0, {
          ...opts,
Severity: Major
Found in packages/eslint/src/api.js - About 40 mins to fix

Function injectIntoLinter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

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

Severity: Minor
Found in packages/eslint/src/api.js - About 35 mins 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

There are no issues that match your filters.

Category
Status