tom-weatherhead/thaw-grammar

View on GitHub

Showing 181 of 181 total issues

Function evaluateValueOp has a Cognitive Complexity of 125 (exceeds 5 allowed). Consider refactoring.
Open

    private evaluateValueOp(
        evaluatedArguments: ISmalltalkValue[],
        globalInfo: ISmalltalkGlobalInfo
    ): ISmalltalkValue {
        evaluatedArguments = evaluatedArguments.map((arg) => unblockValue(arg));
Severity: Minor
Found in src/languages/smalltalk/domain-object-model/operator-usage.ts - About 2 days 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 evaluateValueOp has 315 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private evaluateValueOp(
        evaluatedArguments: ISmalltalkValue[],
        globalInfo: ISmalltalkGlobalInfo
    ): ISmalltalkValue {
        evaluatedArguments = evaluatedArguments.map((arg) => unblockValue(arg));
Severity: Major
Found in src/languages/smalltalk/domain-object-model/operator-usage.ts - About 1 day to fix

    File operator-usage.ts has 597 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // tom-weatherhead/thaw-grammar/src/languages/smalltalk/domain-object-model/operator-usage.ts
    
    import { EvaluationException, Name } from 'thaw-interpreter-core';
    
    import { EnvironmentFrame } from '../../../common/domain-object-model/environment-frame';
    Severity: Major
    Found in src/languages/smalltalk/domain-object-model/operator-usage.ts - About 1 day to fix

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

      export class QuotedConstantWithQuoteKeyword implements IExpression<ISExpression> {
          public readonly typename: string = typenameQuotedConstantWithQuoteKeyword;
          public readonly sexpression: ISExpression;
      
          constructor(sexpression: ISExpression) {
      src/languages/lisp/domain-object-model/quoted-constant-with-apostrophe.ts on lines 17..48

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

      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 class QuotedConstantWithApostrophe implements IExpression<ISExpression> {
          public readonly typename: string = typenameQuotedConstantWithApostrophe;
          public readonly sexpression: ISExpression;
      
          constructor(sexpression: ISExpression) {
      src/languages/lisp/domain-object-model/quoted-constant-with-quote-keyword.ts on lines 19..50

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

      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 objectToString_ApostrophesToQuoteKeywords has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          public objectToString_ApostrophesToQuoteKeywords(expr: unknown): string {
              if (isFunctionDefinition<ISExpression>(expr)) {
                  return `(define ${expr.functionName} (${expr.argList
                      .map((a) => a.name)
                      .join(' ')}) ${this.objectToString_ApostrophesToQuoteKeywords(expr.body)})`;
      Severity: Minor
      Found in src/languages/lisp/domain-object-model/macro-definition.ts - About 6 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 evaluate has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public evaluate(
              globalInfo: IGlobalInfo<ICLUValue>,
              localEnvironment?: IEnvironmentFrame<ICLUValue>,
              options?: unknown
          ): ICLUValue {
      Severity: Minor
      Found in src/languages/clu/domain-object-model/operator-usage.ts - 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

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

          constructor(
              v: string | undefined = undefined,
              expr: ILCExpression | undefined = undefined // To conveniently make a substitution with a single entry.
          ) {
              if (typeof v !== 'undefined' && typeof expr !== 'undefined') {
      src/languages/prolog/domain-object-model/prolog-substitution.ts on lines 14..31

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

      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

          constructor(
              v: string | undefined = undefined,
              expr: IPrologExpression | undefined = undefined // To conveniently make a substitution with a single entry.
          ) {
              if (typeof v !== 'undefined' && typeof expr !== 'undefined') {
      src/languages/lambda-calculus/domain-object-model/substitution.ts on lines 12..29

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

      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 = 0; i < this.Rhs.length; ++i) {
                  const newGoal1 = this.Rhs[i].ApplySubstitution(substitution);
                  const newGoal2 = otherClause.Rhs[i].ApplySubstitution(substitution);
                  const substitution2 = newGoal1.Unify(newGoal2);
      
      
      Severity: Major
      Found in src/languages/prolog/domain-object-model/prolog-clause.ts and 1 other location - About 4 hrs to fix
      src/languages/prolog/domain-object-model/prolog-goal.ts on lines 72..82

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

      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 = 0; i < this.ExpressionList.length; ++i) {
                  const newExpr1 = this.ExpressionList[i].ApplySubstitution(substitution);
                  const newExpr2 = otherNameExpression.ExpressionList[i].ApplySubstitution(substitution);
                  const substitution2 = newExpr1.Unify(newExpr2);
      
      
      Severity: Major
      Found in src/languages/prolog/domain-object-model/prolog-goal.ts and 1 other location - About 4 hrs to fix
      src/languages/prolog/domain-object-model/prolog-clause.ts on lines 140..150

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

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

          public objectToString_ApostrophesToQuoteKeywords(expr: unknown): string {
              if (isFunctionDefinition<ISExpression>(expr)) {
                  return `(define ${expr.functionName} (${expr.argList
                      .map((a) => a.name)
                      .join(' ')}) ${this.objectToString_ApostrophesToQuoteKeywords(expr.body)})`;
      Severity: Major
      Found in src/languages/lisp/domain-object-model/macro-definition.ts - About 3 hrs to fix

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

                } else if (isLetUsage<ISExpression>(expr)) {
                    const bindingsString = expr.bindings
                        .map(
                            ([v, e]: [IVariable<ISExpression>, IExpression<ISExpression>]) =>
                                `(${v} ${this.objectToString_ApostrophesToQuoteKeywords(e)})`
        Severity: Major
        Found in src/languages/lisp/domain-object-model/macro-definition.ts and 1 other location - About 3 hrs to fix
        src/languages/lisp/domain-object-model/macro-definition.ts on lines 144..206

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

        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 (isLetStarUsage<ISExpression>(expr)) {
                    const bindingsString = expr.bindings
                        .map(
                            ([v, e]: [IVariable<ISExpression>, IExpression<ISExpression>]) =>
                                `(${v} ${this.objectToString_ApostrophesToQuoteKeywords(e)})`
        Severity: Major
        Found in src/languages/lisp/domain-object-model/macro-definition.ts and 1 other location - About 3 hrs to fix
        src/languages/lisp/domain-object-model/macro-definition.ts on lines 133..206

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

        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

            public toString(): string {
                const fnBindingAsString = ([v, expr]: [IVariable<T>, IExpression<T>]) => `(${v} ${expr})`;
                const bindingsAsString = this.bindings.map(fnBindingAsString).join(' ');
        
                return `(let (${bindingsAsString}) ${this.expression})`;
        Severity: Major
        Found in src/common/domain-object-model/let-usage.ts and 2 other locations - About 3 hrs to fix
        src/common/domain-object-model/let-star-usage.ts on lines 26..31
        src/languages/scheme/domain-object-model/let-rec-usage.ts on lines 27..32

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

        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

            public toString(): string {
                const fnBindingAsString = ([v, expr]: [IVariable<T>, IExpression<T>]) => `(${v} ${expr})`;
                const bindingsAsString = this.bindings.map(fnBindingAsString).join(' ');
        
                return `(letrec (${bindingsAsString}) ${this.expression})`;
        Severity: Major
        Found in src/languages/scheme/domain-object-model/let-rec-usage.ts and 2 other locations - About 3 hrs to fix
        src/common/domain-object-model/let-star-usage.ts on lines 26..31
        src/common/domain-object-model/let-usage.ts on lines 24..29

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

        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

            public toString(): string {
                const fnBindingAsString = ([v, expr]: [IVariable<T>, IExpression<T>]) => `(${v} ${expr})`;
                const bindingsAsString = this.bindings.map(fnBindingAsString).join(' ');
        
                return `(let* (${bindingsAsString}) ${this.expression})`;
        Severity: Major
        Found in src/common/domain-object-model/let-star-usage.ts and 2 other locations - About 3 hrs to fix
        src/common/domain-object-model/let-usage.ts on lines 24..29
        src/languages/scheme/domain-object-model/let-rec-usage.ts on lines 27..32

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

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

            public evaluate(
                globalInfo: IGlobalInfo<ICLUValue>,
                localEnvironment?: IEnvironmentFrame<ICLUValue>,
                options?: unknown
            ): ICLUValue {
        Severity: Major
        Found in src/languages/clu/domain-object-model/operator-usage.ts - About 3 hrs to fix

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

          export function lcaHeadUsage(
              ll: ILCExpression,
              options: { h?: string; t?: string } = {}
          ): ILCExpression {
              const h = v(options.h, 'h');
          Severity: Major
          Found in src/languages/lambda-calculus/operators.ts and 1 other location - About 3 hrs to fix
          src/languages/lambda-calculus/operators.ts on lines 457..467

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

          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 function lcaTailUsage(
              ll: ILCExpression,
              options: { h?: string; t?: string } = {}
          ): ILCExpression {
              const h = v(options.h, 'h');
          Severity: Major
          Found in src/languages/lambda-calculus/operators.ts and 1 other location - About 3 hrs to fix
          src/languages/lambda-calculus/operators.ts on lines 437..447

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

          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

          Severity
          Category
          Status
          Source
          Language