Microsoft/fast-dna

View on GitHub
packages/web-components/fast-ssr/src/template-parser/template-parser.ts

Summary

Maintainability
F
3 days
Test Coverage

Function parseStringToOpCodes has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

export function parseStringToOpCodes(
    /**
     * The string to parse
     */
    templateString: string,

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

export function parseStringToOpCodes(
    /**
     * The string to parse
     */
    templateString: string,

    Function parseElementNode has 88 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function parseElementNode(node: DefaultTreeElement): void {
            // Track whether the opening tag of an element should be augmented.
            // All constructable custom elements will need to be augmented,
            // as well as any element with attribute bindings
            let augmentOpeningTag = false;

      File template-parser.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /**
       * This file was heavily inspired by {@link https://github.com/lit/lit/tree/main/packages/labs/ssr}, with adjustments to render parse FAST elements.
       * Please see {@link ../ACKNOWLEDGEMENTS.md}
       */
      import {

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

        function traverse(node: DefaultTreeNode | DefaultTreeParentNode, visitor: Visitor) {
            // Templates parsed with `parse()` are parsed as full documents and will contain
            // html, body tags whether the template contains them or not. Skip over visiting and
            // leaving these elements if there is no source-code location, because that indicates
            // they are not in the template string.

        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