MichaReiser/speedy.js

View on GitHub

Showing 100 of 322 total issues

Function rewriteEntryFunction has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    rewriteEntryFunction(name: string, functionDeclaration: ts.FunctionDeclaration): ts.FunctionDeclaration {
        this.loadWasmFunctionIdentifier = this.loadWasmFunctionIdentifier || ts.createUniqueName("loadWasmModule");
        const signature = this.context.typeChecker.getSignatureFromDeclaration(functionDeclaration);

        const bodyStatements: ts.Statement[] = [];

    Function parseSymbolsFromObjectFile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        private parseSymbolsFromObjectFile(objectFile: string): ObjectFileSymbols {
            const output = execLLVM("llvm-nm", [objectFile]);
    
            const symbols = { undefined: new Set<string>(), common: new Set<string>(), defined: new Set<string>() };
            for (const line of output.split("\n")) {
    Severity: Minor
    Found in packages/compiler/src/external-tools/llvm-nm.ts - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function serializeArgumentAndReturnTypes has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private serializeArgumentAndReturnTypes(argumentTypes: ts.Type[], returnType: ts.Type) {
            const types: Types = {};
            const typesToProcess = Array.from(new Set([...argumentTypes, returnType]));
    
            while (typesToProcess.length > 0) {

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

          convert(type: ts.Type, place: TypePlace): llvm.Type {
              if (type.flags & ts.TypeFlags.Any) {
                  return this.getAnyType(place);
              }
      
      

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

      export function generateCondition(condition: ts.Node, whenTrue: llvm.BasicBlock, whenFalse: llvm.BasicBlock, context: CodeGenerationContext): void {
          if (condition.kind === ts.SyntaxKind.ParenthesizedExpression) {
              return generateCondition((condition as ts.ParenthesizedExpression).expression, whenTrue, whenFalse, context);
          }
      
      
      Severity: Minor
      Found in packages/compiler/src/code-generation/util/conditions.ts - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function jsToWasm has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function jsToWasm(jsValue: any, typeName: string, types: Types, objectReferences: Map<object, int>): any {
              const type = types[typeName];
      
              if (!type) { throw new Error("Unknown type " + typeName); }
      
      

        Function typeToCode has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            protected typeToCode(type: ts.Type): string {
                if (type.flags & ts.TypeFlags.BooleanLike) {
                    return "b";
                }
        
        
        Severity: Minor
        Found in packages/compiler/src/code-generation/base-name-mangler.ts - About 1 hr to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function serializeArgumentAndReturnTypes has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private serializeArgumentAndReturnTypes(argumentTypes: ts.Type[], returnType: ts.Type) {
                const types: Types = {};
                const typesToProcess = Array.from(new Set([...argumentTypes, returnType]));
        
                while (typesToProcess.length > 0) {

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

            convert(type: ts.Type, place: TypePlace): llvm.Type {
                if (type.flags & ts.TypeFlags.Any) {
                    return this.getAnyType(place);
                }
        
        

          Function toSupportedType has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function toSupportedType(type: ts.Type, typeChecker: ts.TypeChecker): ts.Type {
              // should never happen but it does!, thanks typescript
              if (typeof(type) === "undefined") {
                  return type;
              }
          Severity: Minor
          Found in packages/compiler/src/typescript-type-checker.ts - About 1 hr to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function generate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              generate(forStatement: ts.ForStatement, context: CodeGenerationContext): void {
                  if (forStatement.initializer) {
                      context.generate(forStatement.initializer);
                  }
          
          

            Function typeToCode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected typeToCode(type: ts.Type): string {
                    if (type.flags & ts.TypeFlags.BooleanLike) {
                        return "b";
                    }
            
            
            Severity: Minor
            Found in packages/compiler/src/code-generation/base-name-mangler.ts - About 1 hr to fix

              Function rewriteSourceFile has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  rewriteSourceFile(sourceFile: ts.SourceFile, requestEmitHelper: (emitHelper: ts.EmitHelper) => void): ts.SourceFile {
                      assert (this.wasmUrl, `No wasm fetch expression set but requested to transform the source file`);
              
                      if (!this.loadWasmFunctionIdentifier) {
                          return sourceFile;

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

                function install() {
                    let llvmConfigPath;
                
                    const configuredLLVM = process.env.LLVM_CONFIG || process.env.npm_config_LLVM_CONFIG;
                
                
                Severity: Minor
                Found in packages/compiler/scripts/llvm-installer.js - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

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

                    private static unifyTypes(binaryExpression: ts.BinaryExpression, context: CodeGenerationContext): ts.Type {
                        function unify(left: ts.Type, right: ts.Type) {
                            if (left === right) {
                                return left;
                            }

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

                    private attributeParameters(fn: llvm.Function, resolvedFunction: ResolvedFunction, context: CodeGenerationContext, object?: ObjectReference) {
                        const parameters = fn.getArguments();
                        let argumentOffset = 0;
                
                        if (object) {
                Severity: Minor
                Found in packages/compiler/src/code-generation/value/function-factory.ts - About 1 hr to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Function wasmToJs has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function wasmToJs(wasmValue: any, typeName: string, types: Types, returnedObjects: Map<int, object>) {
                        const type = types[typeName];
                        if (!type) { throw new Error("Unknown type " + typeName); }
                
                        if (type.primitive) {

                  Function allocateArguments has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private allocateArguments() {
                          const args = this.fn.getArguments().slice();
                  
                          // The this object is passed as first argument
                          if (this.resolvedFunction.classType && this.resolvedFunction.instanceMethod) {

                    Function generateCondition has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function generateCondition(condition: ts.Node, whenTrue: llvm.BasicBlock, whenFalse: llvm.BasicBlock, context: CodeGenerationContext): void {
                        if (condition.kind === ts.SyntaxKind.ParenthesizedExpression) {
                            return generateCondition((condition as ts.ParenthesizedExpression).expression, whenTrue, whenFalse, context);
                        }
                    
                    
                    Severity: Minor
                    Found in packages/compiler/src/code-generation/util/conditions.ts - About 1 hr to fix

                      Function getCallArguments has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected getCallArguments(resolvedFunction: ResolvedFunction, passedArguments: llvm.Value[], callerContext: CodeGenerationContext): llvm.Value[] {
                              const result: llvm.Value[] = [];
                      
                              for (let i = 0; i < resolvedFunction.parameters.length; ++i) {
                                  const parameter = resolvedFunction.parameters[i];
                        Severity
                        Category
                        Status
                        Source
                        Language