MetaPhase-Consulting/State-TalentMAP

View on GitHub
src/utilities.js

Summary

Maintainability
B
5 hrs
Test Coverage
C
79%

Function renderSelectionList has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

export const renderSelectionList = ({ items, selected, ...rest }) => {
  let codeOrText = 'code';
  if (items?.[0]?.text) codeOrText = 'text';
  // only Item Actions/Statuses need to use 'desc_text'
  if (items?.[0]?.desc_text) codeOrText = 'desc_text';
Severity: Minor
Found in src/utilities.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 localStorageToggleValue has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export function localStorageToggleValue(key, value, useDispatch = true, onlyDelete = false) {
  const existingArray = JSON.parse(localStorage.getItem(key)) || [];
  // check if the value matches, either as a string or as a number
  let indexOfId = existingArray.indexOf(value);
  if (indexOfId <= -1) {
Severity: Minor
Found in src/utilities.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 getResult has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const getResult = (result, path, defaultValue, isRate = false) => {
  let value = get(result, path, defaultValue);

  if ((/_date|date_|ted/i).test(path) && value !== defaultValue) {
    value = formatDate(value);
Severity: Minor
Found in src/utilities.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 getCustomLocation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function getCustomLocation(loc, org) {
  if (!loc) return NO_POST;
  // DC Post - org ex. GTM/EX/SDD
  if (get(loc, 'state') === 'DC') return org || NO_POST;
  // Domestic outside of DC - City, State
Severity: Minor
Found in src/utilities.js - About 45 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 scrollToId has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const scrollToId = ({ el, config = {} }) => {
  // Get an element's distance from the top of the page
  const getElemDistance = (elem) => {
    let location = 0;
    if (elem.offsetParent) {
Severity: Minor
Found in src/utilities.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

Avoid too many return statements within this function.
Open

  return x;
Severity: Major
Found in src/utilities.js - About 30 mins to fix

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

    export const mapDuplicates = (data = [], propToCheck = 'custom_description', transformFunc) => data.slice().map((p) => {
      let p$ = { ...p };
      const matching = data.filter(f =>
        f[propToCheck] === p$[propToCheck],
      ) || [];
    Severity: Minor
    Found in src/utilities.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

    There are no issues that match your filters.

    Category
    Status