formal-language/grammar

View on GitHub

Showing 17 of 17 total issues

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

export default function _follow(FIRST, productions) {
    const FOLLOW = new Map(map((i) => [i, new Set()], productions.keys()));

    const couldbelast = new Map(map((i) => [i, new Set()], productions.keys()));

Severity: Minor
Found in src/ll1/_follow.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 alphabet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

export default function alphabet(productions) {
    const abc = new Set();

    for (const unit of productions.values()) {
        for (const rule of unit.values()) {
Severity: Minor
Found in src/grammar/alphabet.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

Function audit has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

export default function* audit({productions}) {
    const phi = _first(productions);

    const FIRST = (rule) => first(phi, rule);

Severity: Minor
Found in src/ll1/audit.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

Function materialize has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default async function materialize(root) {
    // Assert root.type === 'node'

    const parents = [
        {
Severity: Minor
Found in src/ast/materialize.js - About 1 hr to fix

    Function materialize has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export default async function materialize(root) {
        // Assert root.type === 'node'
    
        const parents = [
            {
    Severity: Minor
    Found in src/ast/materialize.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

    Function _children_next_lazy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    export default async function _children_next_lazy(
        eof,
        productions,
        table,
        tape,
    Severity: Minor
    Found in src/ll1/_children_next_lazy.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

    Function _compile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function* _compile(productions) {
        const abc = alphabet(productions);
    
        const phi = _first(productions);
        const pho = _follow(phi, productions);
    Severity: Minor
    Found in src/ll1/_compile.js - About 1 hr to fix

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

      export default async function* flatten(root) {
          // Assert root.type === 'node'
      
          const stack = [
              {
      Severity: Minor
      Found in src/ast/flatten.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

      Function _children_next_lazy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default async function _children_next_lazy(
          eof,
          productions,
          table,
          tape,
      Severity: Minor
      Found in src/ll1/_children_next_lazy.js - About 1 hr to fix

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

                    (a) => [
                        a,
                        next(
                            // eslint-disable-next-line new-cap
                            iter(filter((r) => FIRST(rules.get(r)).has(a), rules.keys())),
        Severity: Major
        Found in src/ll1/_compile.js and 1 other location - About 1 hr to fix
        src/ll1/_compile.js on lines 33..40

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

        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

                    (a) => [
                        a,
                        next(
                            // eslint-disable-next-line new-cap
                            iter(filter((r) => FIRST(rules.get(r)).has(EW), rules.keys())),
        Severity: Major
        Found in src/ll1/_compile.js and 1 other location - About 1 hr to fix
        src/ll1/_compile.js on lines 45..52

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

        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 _parse_lazy has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            eof,
            productions,
            table,
            rule,
            tape,
        Severity: Major
        Found in src/ll1/_parse_lazy.js - About 50 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if (part.type === 'leaf') abc.add(part.terminal);
          Severity: Major
          Found in src/grammar/alphabet.js - About 45 mins to fix

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

            export default function parse(root, start, eof, productions, table, tape) {
            Severity: Minor
            Found in src/ll1/parse.js - About 45 mins to fix

              Function _children_next_lazy has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  eof,
                  productions,
                  table,
                  tape,
                  expected,
              Severity: Minor
              Found in src/ll1/_children_next_lazy.js - About 35 mins to fix

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

                const mapDuplicates = (rules) => {
                    const candidates = new Map();
                    for (const [key, first] of rules) {
                        for (const f of first) {
                            if (candidates.has(f)) candidates.get(f).push(key);
                Severity: Minor
                Found in src/ll1/audit.js - 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

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

                export default async function _children_exhaust(children) {
                    // For await ( const child of children ) {
                    // if ( child.type === 'node' ) await _children_exhaust( child.children ) ;
                    // }
                
                
                Severity: Minor
                Found in src/ast/_children_exhaust.js - 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