MichaReiser/speedy.js

View on GitHub

Showing 100 of 322 total issues

Avoid too many return statements within this function.
Open

            return this.getUndefinedType(place);
Severity: Major
Found in packages/compiler/src/code-generation/util/default-type-converter.ts - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return this.throwUnknownConversionError(type);
    Severity: Major
    Found in packages/compiler/src/code-generation/util/default-type-converter.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return this.convert(type.getNonNullableType(), place);
      Severity: Major
      Found in packages/compiler/src/code-generation/util/default-type-converter.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "?" + this.typeToCode(type.getNonNullableType());
        Severity: Major
        Found in packages/compiler/src/code-generation/base-name-mangler.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/undefined.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return llvm.FunctionType.get(this.convert(callSignature.getReturnType(), place & TypePlace.RETURN_VALUE), parameterTypes, false).getPointerTo();
            Severity: Major
            Found in packages/compiler/src/code-generation/util/default-type-converter.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return ts.createLiteral(value);

                Avoid too many return statements within this function.
                Open

                            return `${objectName}${typeArgumentsPostfix}`;
                Severity: Major
                Found in packages/compiler/src/code-generation/base-name-mangler.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 emit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static emit(program: ts.Program, compilationContext: CompilationContext) {
                          const codeGenerationContextFactory = new DefaultCodeGenerationContextFactory(new NotYetImplementedCodeGenerator());
                          const codeGenerator = new PerFileCodeGenerator(compilationContext.llvmContext, codeGenerationContextFactory);
                  
                          const logUnknownVisitor = new LogUnknownTransformVisitor();
                  Severity: Minor
                  Found in packages/compiler/src/compiler.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 invokeResolvedFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private invokeResolvedFunction(resolvedFunction: ResolvedFunction, args: llvm.Value[], callerContext: CodeGenerationContext) {
                          const llvmFunction = this.getLLVMFunction(resolvedFunction, callerContext, args);
                          assert(llvmFunction.type.isPointerTy() && (llvmFunction.type as llvm.PointerType).elementType.isFunctionTy(), "Expected pointer to a function type");
                  
                          const callArguments = this.getCallArguments(resolvedFunction, args, callerContext);

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

                      getTypeAtLocation(node: ts.Node): ts.Type {
                          let type = this.toSupportedType(this.tsTypeChecker.getTypeAtLocation(node));
                  
                          // e.g. when const x: int[] = [] then the type of [] is never[] that is quite unfortunate. Take the contextual
                          // type information into consideration in this case (but do not otherwise. Otherwise let x: number = 3 returns unexpected results.
                  Severity: Minor
                  Found in packages/compiler/src/typescript-type-checker.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static create(type: ts.ObjectType, context: CodeGenerationContext) {
                          const baseTypes = type.getBaseTypes();
                  
                          const declaration = type.getSymbol().valueDeclaration as ts.ClassDeclaration;
                          if (baseTypes && type.getBaseTypes().length > 0) {
                  Severity: Minor
                  Found in packages/compiler/src/code-generation/value/speedy-js-class-reference.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 isFunctionType has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function isFunctionType(type: ts.Type) {
                      if (type.flags & ts.TypeFlags.Union) {
                          const unionType = type as ts.UnionType;
                  
                          if (unionType.types.length === 2 && unionType.types.some(t => !!(t.flags & ts.TypeFlags.Undefined))) {
                  Severity: Minor
                  Found in packages/compiler/src/code-generation/util/types.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 toLlvmArgumentTypes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private toLlvmArgumentTypes(resolvedFunction: ResolvedFunction,
                                                  numberOfArguments: number,
                                                  context: CodeGenerationContext,
                                                  objectReference?: ObjectReference) {
                          const argumentTypes = objectReference ? [this.typeConverter.convert(objectReference.type, TypePlace.THIS)] : [];
                  Severity: Minor
                  Found in packages/compiler/src/code-generation/value/function-factory.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 createTransformer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function createTransformer(transformVisitor: TransformVisitor, transformationContext: ts.TransformationContext): ts.Transformer<ts.SourceFile> {
                      const context: TransformVisitorContext = {
                          requestEmitHelper(emitHelper: ts.EmitHelper): void {
                              transformationContext.requestEmitHelper(emitHelper);
                          },
                  Severity: Minor
                  Found in packages/compiler/src/transform/transform-visitor.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

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

                  export function invoke(callee: FunctionPointer, args: llvm.Value[], returnType: llvm.Type, callerContext: CodeGenerationContext, options?: InvokeOptions) {
                      const functionType = callee.type.elementType;
                      const initializedOptions = options || {};
                  
                      assert(args.length === functionType.numParams, `Calling function with less arguments than declared parameters`);
                  Severity: Minor
                  Found in packages/compiler/src/code-generation/util/functions.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 verifyIsSupportedSpeedyJSFunction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function verifyIsSupportedSpeedyJSFunction(declaration: ts.Declaration, context: CodeGenerationContext) {
                      // tslint:disable-next-line: max-line-length
                      if (!(declaration.kind === ts.SyntaxKind.FunctionDeclaration || declaration.kind === ts.SyntaxKind.MethodDeclaration || declaration.kind === ts.SyntaxKind.Constructor)) {
                          throw CodeGenerationDiagnostics.unsupportedFunctionDeclaration(declaration);
                      }
                  Severity: Minor
                  Found in packages/compiler/src/code-generation/value/speedyjs-function-factory.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

                  Severity
                  Category
                  Status
                  Source
                  Language