parpeoficial/stackerjs-utils

View on GitHub

Showing 26 of 26 total issues

Function CNPJ has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export default function CNPJ(cnpj) 
{
    this.validate = () => 
    {
        let value = this.clear();
Severity: Minor
Found in src/Utils/BR/CNPJ.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

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

        if (rule.name === "min" && ((typeof data[rule.field] === "string" && data[rule.field].length > rule.value) || (typeof data[rule.field] === "number" && data[rule.field] > rule.value)))
            return;
Severity: Major
Found in src/Factories/ValidatorFactory.js and 1 other location - About 2 hrs to fix
src/Factories/ValidatorFactory.js on lines 57..58

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 93.

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

        if (rule.name === "max" && ((typeof data[rule.field] === "string" && data[rule.field].length < rule.value) || (typeof data[rule.field] === "number" && data[rule.field] < rule.value)))
            return;
Severity: Major
Found in src/Factories/ValidatorFactory.js and 1 other location - About 2 hrs to fix
src/Factories/ValidatorFactory.js on lines 54..55

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 93.

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

Function CPF has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

export default function CPF(cpf) 
{
    this.validate = () => 
    {
        let value = this.clear();
Severity: Minor
Found in src/Utils/BR/CPF.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 CPF has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function CPF(cpf) 
{
    this.validate = () => 
    {
        let value = this.clear();
Severity: Major
Found in src/Utils/BR/CPF.js - About 2 hrs to fix

    Function CNPJ has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function CNPJ(cnpj) 
    {
        this.validate = () => 
        {
            let value = this.clear();
    Severity: Minor
    Found in src/Utils/BR/CNPJ.js - About 1 hr to fix

      Function checkupRule has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          checkupRule(rule, data, errors) 
          {
              if (rule.name === "string" && typeof data[rule.field] === "string") return;
      
              if (rule.name === "number" && typeof data[rule.field] === "number") return;
      Severity: Minor
      Found in src/Factories/ValidatorFactory.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

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

              for (let i = length; i >= 1; i--) 
              {
                  summ += numbers.charAt(length - i) * pos--;
                  if (pos < 2) pos = 9;
              }
      Severity: Major
      Found in src/Utils/BR/CNPJ.js and 1 other location - About 1 hr to fix
      src/Utils/BR/CNPJ.js on lines 15..19

      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 63.

      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

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

              for (let i = length; i >= 1; i--) 
              {
                  summ += numbers.charAt(length - i) * pos--;
                  if (pos < 2) pos = 9;
              }
      Severity: Major
      Found in src/Utils/BR/CNPJ.js and 1 other location - About 1 hr to fix
      src/Utils/BR/CNPJ.js on lines 29..33

      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 63.

      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

      Function isURI has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const isURI = value => 
      {
          let parts, scheme, authority, path;
          if (!isString(value)) 
          {
      Severity: Minor
      Found in src/Utils/String.js - About 1 hr to fix

        Function NIF has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default function NIF(nif) 
        {
            this.validate = () => 
            {
                let value = this.clear(nif);
        Severity: Minor
        Found in src/Utils/PT/NIF.js - About 1 hr to fix

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

          export default function NIF(nif) 
          {
              this.validate = () => 
              {
                  let value = this.clear(nif);
          Severity: Minor
          Found in src/Utils/PT/NIF.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

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

                  for (let i = 1; i <= 9; i++)
                      summ = summ + parseInt(value.substring(i - 1, i)) * (11 - i);
          Severity: Major
          Found in src/Utils/BR/CPF.js and 1 other location - About 1 hr to fix
          src/Utils/BR/CPF.js on lines 21..22

          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 56.

          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

                  for (let i = 1; i <= 10; i++)
                      summ = summ + parseInt(value.substring(i - 1, i)) * (12 - i);
          Severity: Major
          Found in src/Utils/BR/CPF.js and 1 other location - About 1 hr to fix
          src/Utils/BR/CPF.js on lines 11..12

          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 56.

          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

          Function validate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              this.validate = () => 
              {
                  let value = this.clear();
                  if (value.length !== 14 || /^(\d)\1+$/.test(value)) return false;
          
          
          Severity: Minor
          Found in src/Utils/BR/CNPJ.js - About 1 hr to fix

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

            export const isLessThan = (value, comparator) => 
            {
                if (!isNumber(value) || !isNumber(comparator)) 
                {
                    return false;
            Severity: Minor
            Found in src/Utils/Number.js and 1 other location - About 45 mins to fix
            src/Utils/Number.js on lines 19..26

            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 50.

            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 const isGreaterThan = (value, comparator) => 
            {
                if (!isNumber(value) || !isNumber(comparator)) 
                {
                    return false;
            Severity: Minor
            Found in src/Utils/Number.js and 1 other location - About 45 mins to fix
            src/Utils/Number.js on lines 10..17

            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 50.

            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

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

            export const isURI = value => 
            {
                let parts, scheme, authority, path;
                if (!isString(value)) 
                {
            Severity: Minor
            Found in src/Utils/String.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;
            Severity: Major
            Found in src/Factories/ValidatorFactory.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return false;
              Severity: Major
              Found in src/Utils/String.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language