aureooms/texshake

View on GitHub
src/transform/shaker.js

Summary

Maintainability
F
4 days
Test Coverage
A
99%

File shaker.js has 566 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { StopIteration } from '@aureooms/js-itertools' ;
import { ast } from '@aureooms/js-grammar' ;
import tape from '@aureooms/js-tape' ;

import visitor from './visitor' ;
Severity: Major
Found in src/transform/shaker.js - About 1 day to fix

    Function begin-environment has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        "begin-environment": async ( tree , match , ctx ) => {
    
          const it = iter(tree.children) ;
    
          const begincmd = await next(it) ; // \begin
    Severity: Minor
    Found in src/transform/shaker.js - About 1 hr to fix

      Function end-environment has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          "end-environment": async ( tree , match , ctx ) => {
      
            const it = iter(tree.children) ;
      
            const endcmd = await next(it) ; // \end
      Severity: Minor
      Found in src/transform/shaker.js - About 1 hr to fix

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

            "ifcmd": async ( tree , match , ctx ) => {
        
              const it = iter(tree.children) ;
        
              const ifcmd = await next(it) ; // \if...
        Severity: Minor
        Found in src/transform/shaker.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

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

            "othercmd": async ( tree , match , ctx ) => {
        
              const it = iter(tree.children) ;
        
              const othercmd = await next(it) ;
        Severity: Minor
        Found in src/transform/shaker.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

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

            "begin-environment": async ( tree , match , ctx ) => {
        
              const it = iter(tree.children) ;
        
              const begincmd = await next(it) ; // \begin
        Severity: Minor
        Found in src/transform/shaker.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 chain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        async function* chain ( iterables ) {
        
          for ( const iterable of iterables ) {
            if ( iterable[Symbol.iterator] ) yield* iterable ;
            else for await ( const item of iterable ) yield item ;
        Severity: Minor
        Found in src/transform/shaker.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

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

            "truecmd" : async ( tree , _ , ctx ) => {
              const truecmd = await next(iter(tree.children)) ;
              const buffer = truecmd.buffer;
              const variable = buffer.substring(1, buffer.length-4);
              ctx.variables.get('if').set(variable, true);
        Severity: Major
        Found in src/transform/shaker.js and 1 other location - About 3 hrs to fix
        src/transform/shaker.js on lines 487..493

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

        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

            "falsecmd" : async ( tree , _ , ctx ) => {
              const falsecmd = await next(iter(tree.children)) ;
              const buffer = falsecmd.buffer;
              const variable = buffer.substring(1, buffer.length-5);
              ctx.variables.get('if').set(variable, false);
        Severity: Major
        Found in src/transform/shaker.js and 1 other location - About 3 hrs to fix
        src/transform/shaker.js on lines 495..501

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

        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 3 locations. Consider refactoring.
        Open

            "{cmd}[nargs][default]{anything}": async ( tree , _ , { variables } ) => {
              tree = await ast.materialize(tree);
              const [ cmd , nargs , dflt , blob ] = await commandDefinitionParser["{cmd}[nargs][default]{anything}"](tree) ;
              return processCommandRedefinition( variables.get('cmd') , cmd , [nargs , dflt , blob], tree ) ;
            } ,
        Severity: Major
        Found in src/transform/shaker.js and 2 other locations - About 2 hrs to fix
        src/transform/shaker.js on lines 588..592
        src/transform/shaker.js on lines 594..598

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

        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 3 locations. Consider refactoring.
        Open

            "*cmd[nargs][default]{anything}": async ( tree , _ , { variables } ) => {
              tree = await ast.materialize(tree);
              const [ cmd , nargs , dflt , blob ] = await commandDefinitionParser["*cmd[nargs][default]{anything}"](tree) ;
              return processCommandRedefinition( variables.get('cmd') , cmd , [nargs , dflt , blob], tree ) ;
            } ,
        Severity: Major
        Found in src/transform/shaker.js and 2 other locations - About 2 hrs to fix
        src/transform/shaker.js on lines 582..586
        src/transform/shaker.js on lines 588..592

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

        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 3 locations. Consider refactoring.
        Open

            "cmd[nargs][default]{anything}": async ( tree , _ , { variables } ) => {
              tree = await ast.materialize(tree);
              const [ cmd , nargs , dflt , blob ] = await commandDefinitionParser["cmd[nargs][default]{anything}"](tree) ;
              return processCommandRedefinition( variables.get('cmd') , cmd , [nargs , dflt , blob], tree ) ;
            } ,
        Severity: Major
        Found in src/transform/shaker.js and 2 other locations - About 2 hrs to fix
        src/transform/shaker.js on lines 582..586
        src/transform/shaker.js on lines 594..598

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

        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

            "{cmd}[nargs][default]{anything}": async ( tree , _ , { variables } ) => {
              tree = await ast.materialize(tree);
              const [ cmd , nargs , dflt , blob ] = await commandDefinitionParser["{cmd}[nargs][default]{anything}"](tree) ;
              return processCommandDefinition( variables.get('cmd') , cmd, [ nargs , dflt ,blob ]);
            } ,
        Severity: Major
        Found in src/transform/shaker.js and 1 other location - About 2 hrs to fix
        src/transform/shaker.js on lines 564..568

        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

            "cmd[nargs][default]{anything}": async ( tree , _ , { variables } ) => {
              tree = await ast.materialize(tree);
              const [ cmd , nargs , dflt , blob ] = await commandDefinitionParser["cmd[nargs][default]{anything}"](tree) ;
              return processCommandDefinition( variables.get('cmd') , cmd, [ nargs , dflt ,blob ]);
            } ,
        Severity: Major
        Found in src/transform/shaker.js and 1 other location - About 2 hrs to fix
        src/transform/shaker.js on lines 558..562

        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 4 locations. Consider refactoring.
        Open

            "renewenvironment": async ( tree , match , ctx ) => {
              const it = iter(tree.children) ;
              await next(it) ; // \renewenvironment
              const envdef = await next(it) ;
              return t( envdef , match , ctx ) ;
        Severity: Major
        Found in src/transform/shaker.js and 3 other locations - About 1 hr to fix
        src/transform/shaker.js on lines 516..521
        src/transform/shaker.js on lines 523..528
        src/transform/shaker.js on lines 530..535

        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

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

            "newcommand": async ( tree , match , ctx ) => {
              const it = iter(tree.children) ;
              await next(it) ; // \newcommand
              const cmddef = await next(it) ;
              return t( cmddef , match , ctx ) ;
        Severity: Major
        Found in src/transform/shaker.js and 3 other locations - About 1 hr to fix
        src/transform/shaker.js on lines 523..528
        src/transform/shaker.js on lines 530..535
        src/transform/shaker.js on lines 537..542

        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

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

            "renewcommand": async ( tree , match , ctx ) => {
              const it = iter(tree.children) ;
              await next(it) ; // \renewcommand
              const cmddef = await next(it) ;
              return t( cmddef , match , ctx ) ;
        Severity: Major
        Found in src/transform/shaker.js and 3 other locations - About 1 hr to fix
        src/transform/shaker.js on lines 516..521
        src/transform/shaker.js on lines 530..535
        src/transform/shaker.js on lines 537..542

        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

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

            "newenvironment": async ( tree , match , ctx ) => {
              const it = iter(tree.children) ;
              await next(it) ; // \newenvironment
              const envdef = await next(it) ;
              return t( envdef , match , ctx ) ;
        Severity: Major
        Found in src/transform/shaker.js and 3 other locations - About 1 hr to fix
        src/transform/shaker.js on lines 516..521
        src/transform/shaker.js on lines 523..528
        src/transform/shaker.js on lines 537..542

        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

        There are no issues that match your filters.

        Category
        Status