MichaReiser/speedy.js

View on GitHub
packages/compiler/src/code-generation/value/primitive.ts

Summary

Maintainability
C
1 day
Test Coverage

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

    static toBoolean(value: Value | llvm.Value, valueType: ts.Type, context: CodeGenerationContext) {
        const llvmValue = value instanceof llvm.Value ? value : value.generateIR(context);

        if (valueType.flags & ts.TypeFlags.BooleanLike) {
            return llvmValue;
Severity: Minor
Found in packages/compiler/src/code-generation/value/primitive.ts - 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

Avoid too many return statements within this function.
Open

            return context.builder.createICmpNE(llvmValue, llvm.Constant.getNullValue(llvmValue.type), `${llvmValue.name}AsBool`);
Severity: Major
Found in packages/compiler/src/code-generation/value/primitive.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return undefined;
    Severity: Major
    Found in packages/compiler/src/code-generation/value/primitive.ts - About 30 mins to fix

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

          static toNumber(value: Value, valueType: ts.Type, numberType: ts.Type, context: CodeGenerationContext) {
              let numberValue: llvm.Value;
              const llvmValue = value.generateIR(context);
      
              if (valueType.flags & ts.TypeFlags.BooleanLike) {
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts - 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 castImplicit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          castImplicit(type: ts.Type, context: CodeGenerationContext): Value | undefined {
              if (this.type === type) {
                  return this;
              }
      
      
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts - 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 toInt32 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          static toInt32(value: Value, valueType: ts.Type, int32Type: ts.Type, context: CodeGenerationContext) {
              let intValue: llvm.Value;
      
              if (valueType.flags & ts.TypeFlags.IntLike) {
                  intValue = value.generateIR(context);
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts - 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

              if (valueType.flags & ts.TypeFlags.IntLike) {
                  return context.builder.createICmpNE(llvmValue, llvm.ConstantInt.get(context.llvmContext, 0), `${llvmValue.name}AsBool`);
              }
      Severity: Major
      Found in packages/compiler/src/code-generation/value/primitive.ts and 1 other location - About 1 hr to fix
      packages/compiler/src/code-generation/value/primitive.ts on lines 89..91

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

      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 (valueType.flags & ts.TypeFlags.NumberLike) {
                  return context.builder.createFCmpONE(llvmValue, llvm.ConstantFP.get(context.llvmContext, 0), `${llvmValue.name}AsBool`);
              }
      Severity: Major
      Found in packages/compiler/src/code-generation/value/primitive.ts and 1 other location - About 1 hr to fix
      packages/compiler/src/code-generation/value/primitive.ts on lines 85..87

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

      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 (valueType.flags & ts.TypeFlags.BooleanLike) {
                  numberValue = context.builder.createUIToFP(llvmValue, llvm.Type.getDoubleTy(context.llvmContext), `${llvmValue.name}AsNumber`);
              } else if (valueType.flags & ts.TypeFlags.IntLike) {
                  numberValue = context.builder.createSIToFP(llvmValue, llvm.Type.getDoubleTy(context.llvmContext), `${llvmValue.name}AsNumber`);
              } else if (valueType.flags & ts.TypeFlags.NumberLike) {
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts and 1 other location - About 55 mins to fix
      packages/compiler/src/code-generation/value/primitive.ts on lines 118..128

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

      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

          static false(context: CodeGenerationContext, boolType: ts.Type) {
              return new Primitive(llvm.ConstantInt.getFalse(context.llvmContext), boolType);
          }
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts and 1 other location - About 55 mins to fix
      packages/compiler/src/code-generation/value/primitive.ts on lines 20..22

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

      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

          static true(context: CodeGenerationContext, type: ts.Type) {
              return new Primitive(llvm.ConstantInt.getTrue(context.llvmContext), type);
          }
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts and 1 other location - About 55 mins to fix
      packages/compiler/src/code-generation/value/primitive.ts on lines 30..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 54.

      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 (valueType.flags & ts.TypeFlags.IntLike) {
                  numberValue = context.builder.createSIToFP(llvmValue, llvm.Type.getDoubleTy(context.llvmContext), `${llvmValue.name}AsNumber`);
              } else if (valueType.flags & ts.TypeFlags.NumberLike) {
                  numberValue = llvmValue;
              } else if (valueType.flags & ts.TypeFlags.Undefined) {
      Severity: Minor
      Found in packages/compiler/src/code-generation/value/primitive.ts and 1 other location - About 55 mins to fix
      packages/compiler/src/code-generation/value/primitive.ts on lines 116..128

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

      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