mjurczyk/json-viewer

View on GitHub

Showing 4 of 4 total issues

Function prettyPrint has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

export const prettyPrint = (
  key = null,
  value = '',
  indent = 0,
  colorOutput = false,
Severity: Minor
Found in src/utils/console/pretty-print/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 getAutoCompletion has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const getAutoCompletion = (current, argv = {}) => {
  if (argv && argv._) {
    const filePath = argv._[1];
    const filePathIsString = typeof filePath === 'string';
    const jsonBranch = argv._[2];
Severity: Minor
Found in src/utils/cli/get-auto-completion.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

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

export const readJsonFile = (filepath) => {
  const normalizedPath = filepath && normalize(filepath);
  const isNil = R.isNil(normalizedPath);
  const isString = typeof normalizedPath === 'string';
  const isUnreadable = isString && jetpack.exists(normalizedPath) !== 'file';
Severity: Minor
Found in src/utils/files/read-json-file.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

Function writeJsonFile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const writeJsonFile = (filepath, data = {}) => {
  const isString = typeof filepath === 'string';
  const normalizedPath = isString && filepath && normalize(filepath);
  const isNil = R.isNil(normalizedPath);

Severity: Minor
Found in src/utils/files/write-json-file.js - About 25 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

Severity
Category
Status
Source
Language