jaumard/ecmas-annotations

View on GitHub

Showing 20 of 20 total issues

Function parseAnnotations has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

  parseAnnotations(className, target, comment, annotationsToFind, filePath) {

    const ss = new StringScanner(comment)

    const annotations = []
Severity: Minor
Found in lib/reader.js - About 5 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 parseSource has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  parseSource(source) {

    const metadata = new Metadata()
    const ss = new StringScanner(source)

Severity: Minor
Found in lib/parseres5.js - About 5 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 parse has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  parse(reader, annotationsToFind, string) {

    const tokens = this.tokenize(string)
    let fixedString = ''

Severity: Minor
Found in lib/attribute-parser.js - About 4 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 parseSource has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

  parseSource(source) {

    const metadata = new Metadata()
    const ss = new StringScanner(source)

Severity: Minor
Found in lib/parseres6.js - 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 parse has 90 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  parse(reader, annotationsToFind, string) {

    const tokens = this.tokenize(string)
    let fixedString = ''

Severity: Major
Found in lib/attribute-parser.js - About 3 hrs to fix

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

      parseFile(path) {
        const stat = fs.lstatSync(path)
        if (!stat || !stat.isFile()) {
          return null
        }
    Severity: Major
    Found in lib/parseres5.js and 1 other location - About 3 hrs to fix
    lib/parseres6.js on lines 51..59

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

    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

      parseFile(path) {
        const stat = fs.lstatSync(path)
        if (!stat || !stat.isFile()) {
          return null
        }
    Severity: Major
    Found in lib/parseres6.js and 1 other location - About 3 hrs to fix
    lib/parseres5.js on lines 73..81

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

    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 parseSource has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      parseSource(source) {
    
        const metadata = new Metadata()
        const ss = new StringScanner(source)
    
    
    Severity: Major
    Found in lib/parseres5.js - About 3 hrs to fix

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

              if (match != null) {
      
                metadata.constructor = {
                  type: Metadata.CONSTRUCTOR_FUNCTION_VARIABLE,
                  line: lineNumber,
      Severity: Major
      Found in lib/parseres5.js and 1 other location - About 2 hrs to fix
      lib/parseres5.js on lines 119..130

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

      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 (match != null) {
      
                metadata.constructor = {
                  type: Metadata.CONSTRUCTOR_FUNCTION,
                  line: lineNumber,
      Severity: Major
      Found in lib/parseres5.js and 1 other location - About 2 hrs to fix
      lib/parseres5.js on lines 135..146

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

      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 parseSource has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        parseSource(source) {
      
          const metadata = new Metadata()
          const ss = new StringScanner(source)
      
      
      Severity: Major
      Found in lib/parseres6.js - About 2 hrs to fix

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

              properties.forEach(function(propertyMetadata) {
                const propertyAnnotation = this.parsePropertyAnnotations(propertyMetadata.className, propertyMetadata.name, propertyMetadata.comment, path)
                this.propertyAnnotations.push.apply(this.propertyAnnotations, propertyAnnotation)
              }.bind(this))
        Severity: Major
        Found in lib/reader.js and 1 other location - About 2 hrs to fix
        lib/reader.js on lines 73..76

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

        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

              methods.forEach(function(methodMetadata) {
                const methodAnnotation = this.parseMethodAnnotations(methodMetadata.className, methodMetadata.name, methodMetadata.comment, path)
                this.methodAnnotations.push.apply(this.methodAnnotations, methodAnnotation)
              }.bind(this))
        Severity: Major
        Found in lib/reader.js and 1 other location - About 2 hrs to fix
        lib/reader.js on lines 80..83

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

        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 parseAnnotations has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          parseAnnotations(className, target, comment, annotationsToFind, filePath) {
        
            const ss = new StringScanner(comment)
        
            const annotations = []
        Severity: Major
        Found in lib/reader.js - About 2 hrs to fix

          Function parse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            parse(path, mode) {
              if (!mode) {
                mode = Reader.ES6
              }
          
          
          Severity: Minor
          Found in lib/reader.js - About 1 hr to fix

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

              parse(path, mode) {
                if (!mode) {
                  mode = Reader.ES6
                }
            
            
            Severity: Minor
            Found in lib/reader.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

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

                  else if (part.trim()[part.trim().length - 1] === '}' && !part.trim().match(/(.*)=\{/)) {
                    isObject = true
                  }
            Severity: Minor
            Found in lib/attribute-parser.js and 1 other location - About 55 mins to fix
            lib/attribute-parser.js on lines 71..76

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

            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

                  else if (part.trim()[part.trim().length - 1] === ']' && !part.trim().match(/(.*)=\[/)) {
                    isArray = true
                  }
                  else if (part.trim()[part.trim().length - 1] === '}' && !part.trim().match(/(.*)=\{/)) {
                    isObject = true
            Severity: Minor
            Found in lib/attribute-parser.js and 1 other location - About 55 mins to fix
            lib/attribute-parser.js on lines 74..76

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

            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

            Avoid deeply nested control flow statements.
            Open

                        if (open === close) {
                          done = true
                        }
            Severity: Major
            Found in lib/reader.js - About 45 mins to fix

              Consider simplifying this complex logical expression.
              Open

                        if ((isArray && part.trim().match(/(.*)=\[/)) ||
                          (isObject && part.trim().match(/(.*)=\{/)) ||
                          (isAnnotation && part.trim().match(/(.*)=@(.*)\(/))) {
              
                          found = true
              Severity: Major
              Found in lib/attribute-parser.js - About 40 mins to fix
                Severity
                Category
                Status
                Source
                Language