Showing 92 of 92 total issues

Function replaceByTemplate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function replaceByTemplate(str: string, map: Record<string, TextNumber>): string {
  let cmpString = '',
    offset = 0,
    find = -1,
    addString = ''
Severity: Minor
Found in src/string/strtr.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 equals has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export default function equals(first: any, second: any): boolean {
  if (first === second) {
    return true
  }

Severity: Minor
Found in src/core/equals.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 toNumber has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export default function toNumber(value: any): number {
  if (typeof value === 'number') {
    return value
  }

Severity: Minor
Found in src/to/toNumber.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 toString has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export default function toString(value: any): string {
  if (Array.isArray(value)) {
    return value.toString()
  }

Severity: Minor
Found in src/to/toString.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 merge has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function merge<T extends Partial<record>>(original: Partial<T>, ...values: Partial<T>[]): T {
  const ln = values.length
  let i = 0,
    object: Partial<T>,
    key: PropertyKey,
Severity: Minor
Found in src/object/merge.ts - About 1 hr to fix

    Function number has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function number(
      value: TextNumber,
      decimals: number = 2,
      decPoint: string = '.',
      thousandsSeparator: string = ',',
    Severity: Minor
    Found in src/format/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 camelCase has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    const camelCase = (input: string | string[], options?: CamelCaseType): string => {
      options = {
        pascalCase: false,
        ...(options ? options : {}),
      }
    Severity: Minor
    Found in src/string/camelCase.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 intWord has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      value: TextNumber,
      units: string[] = UnitsDefault,
      kilo: number = 1000,
      decimals: number = 2,
      decPoint: string = '.',
    Severity: Major
    Found in src/format/intWord.ts - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                if (j === subLn - 1) {
                  if (Array.isArray(temporary) && key === '') {
                    temporary.push(value)
                  } else {
                    temporary[key] = value
      Severity: Major
      Found in src/object/fromQueryString.ts - About 45 mins to fix

        Function toArray has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function toArray(value: any = []): any[] {
          if (isNil(value)) {
            return []
          }
        
        
        Severity: Minor
        Found in src/to/toArray.ts - 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 toFinite has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        export default function toFinite(value: any): number {
          if (!value) {
            return value === 0 ? value : 0
          }
          value = toNumber(value)
        Severity: Minor
        Found in src/to/toFinite.ts - 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

        Avoid deeply nested control flow statements.
        Open

                  if (!Array.isArray(object[name])) {
                    object[name] = [object[name]]
                  }
        Severity: Major
        Found in src/object/fromQueryString.ts - About 45 mins to fix

          Function fileSize has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            size: TextNumber,
            kilo: number = 1024,
            decimals: number = 2,
            decPoint: string = '.',
            thousandsSeparator: string = ',',
          Severity: Minor
          Found in src/format/fileSize.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (!isEmpty(r)) {
                          a.push(r)
                        }
            Severity: Major
            Found in src/object/removeEmpty.ts - About 45 mins to fix

              Function isEmpty has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function isEmpty(...parameters: any[]): boolean {
                const invalid = parameters.some(parameter => {
                  switch (Object.prototype.toString.call(parameter)) {
                    case '[object String]':
                      if (parameter.trim().length) return true
              Severity: Minor
              Found in src/is/isEmpty.ts - 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 sum has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function sum(object: Record<PropertyKey, TextNumber | boolean | Function>): number {
                let result = 0
                for (const key in object) {
                  let value = object[key]
                  if (value instanceof Function) {
              Severity: Minor
              Found in src/object/sum.ts - 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 readdirP has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              async function* readdirP(dir: string): AsyncGenerator<string> {
                for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
                  if (entry.isDirectory()) {
                    for await (const sub of readdirP(path.join(dir, entry.name))) {
                      yield sub
              Severity: Minor
              Found in .scripts/rename.ts - 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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              export function isStrings(...parameters: any[]): boolean {
                return !parameters.some(parameter => !isString(parameter))
              }
              Severity: Minor
              Found in src/is/isString.ts and 1 other location - About 40 mins to fix
              src/is/isDate.ts on lines 6..8

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              export function isDates(...parameters: any[]): boolean {
                return !parameters.some(parameter => !isDate(parameter))
              }
              Severity: Minor
              Found in src/is/isDate.ts and 1 other location - About 40 mins to fix
              src/is/isString.ts on lines 4..6

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Consider simplifying this complex logical expression.
              Open

                  } else if (
                    isLastCharUpper &&
                    isLastLastCharUpper &&
                    /[A-Za-z]/.test(character) &&
                    character.toLowerCase() === character
              Severity: Major
              Found in src/string/camelCase.ts - About 40 mins to fix
                Severity
                Category
                Status
                Source
                Language