integreat-io/integreat-transformers

View on GitHub

Showing 12 of 14 total issues

Function uriPart has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

const uriPart: Transformer = () => () => (value, state) =>
  mapAny(function (value) {
    if (value === null || value === undefined) {
      return undefined
    }
Severity: Minor
Found in src/uriPart.ts - 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 truncate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

const truncate = (length?: number, postfix?: string) => {
  if (typeof length === 'number') {
    // Return truncate function if there is a specified length ...
    const postfixLength = typeof postfix === 'string' ? postfix.length : 0
    const cutLength = postfixLength < length ? length - postfixLength : length
Severity: Minor
Found in src/truncate.ts - 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 castDate has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

export function castDate(
  value: unknown,
  zone?: string,
  format?: string,
  isSeconds = false,
Severity: Minor
Found in src/date.ts - 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 prepareSize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const transformer: Transformer = function prepareSize() {
  return () =>
    function size(data) {
      return isNumber(data)
        ? String(data).length
Severity: Minor
Found in src/size.ts - 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 format has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

function format(props: Props) {
  const { format: formatStr, path, ...modifiers } = props
  const isSeconds = props.isSeconds === true // Make sure this is true and not just truthy
  const setPath = typeof path === 'string' ? `>${path}` : undefined
  const pathSetter = getPathOrData(setPath) // Works as a setter due to the `>`
Severity: Minor
Found in src/date.ts - 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 castNumber has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

export const castNumber = (precision?: number) => {
  const precisionProduct =
    typeof precision === 'number' ? Math.pow(10, precision) : undefined

  return function castNumber(value: unknown) {
Severity: Minor
Found in src/number.ts - 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 modifyDate has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  date: DateTime,
  add?: PeriodObject,
  subtract?: PeriodObject,
  set?: PeriodObject,
  data?: unknown,
Severity: Minor
Found in src/date.ts - About 35 mins to fix

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

    const transformer: Transformer = function round({
      precision,
      roundTowardsInfinity = false,
    }: Props) {
      const roundFn =
    Severity: Minor
    Found in src/round.ts - 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 await pathSetter(dateTime.toSeconds())
    Severity: Major
    Found in src/date.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return undefined
      Severity: Major
      Found in src/number.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              return numberOrUndefined(value.getTime())
        Severity: Major
        Found in src/number.ts - About 30 mins to fix

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

            (from: string, to: string) =>
            (rev = false) =>
              function replace(data: unknown) {
                if (typeof data !== 'string') {
                  return data
          Severity: Minor
          Found in src/replace.ts - 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