MichaReiser/speedy.js

View on GitHub

Showing 100 of 322 total issues

Function __moduleLoader has 373 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function __moduleLoader(this: any, wasmUri: string, options: Options): ModuleLoader {
    const PTR_SIZE = 4;
    const PTR_SHIFT = Math.log2(PTR_SIZE);

    function sizeOf(type: string): int {

    Function __moduleLoader has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
    Open

    function __moduleLoader(this: any, wasmUri: string, options: Options): ModuleLoader {
        const PTR_SIZE = 4;
        const PTR_SHIFT = Math.log2(PTR_SIZE);
    
        function sizeOf(type: string): int {

    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

    File binary-expression.spec.ts has 719 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class SimpleClass {}
    
    async function addInts(x: int, y: int) {
        "use speedyjs";
    
    
    Severity: Major
    Found in packages/compiler/__integrationtests__/binary-expression.spec.ts - About 1 day to fix

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

          generate(binaryExpression: ts.BinaryExpression, context: CodeGenerationContext): Value {
              const leftType = context.typeChecker.getTypeAtLocation(binaryExpression.left);
              const rightType = context.typeChecker.getTypeAtLocation(binaryExpression.right);
              const resultType = context.typeChecker.getTypeAtLocation(binaryExpression);
      
      

        Function generate has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
        Open

            generate(binaryExpression: ts.BinaryExpression, context: CodeGenerationContext): Value {
                const leftType = context.typeChecker.getTypeAtLocation(binaryExpression.left);
                const rightType = context.typeChecker.getTypeAtLocation(binaryExpression.right);
                const resultType = context.typeChecker.getTypeAtLocation(binaryExpression);
        
        

        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

        LogUnknownTransformVisitor has 46 functions (exceeds 20 allowed). Consider refactoring.
        Open

        export class LogUnknownTransformVisitor implements TransformVisitor {
            visitSourceFile(sourceFile: ts.SourceFile, context: TransformVisitorContext): ts.SourceFile {
                return context.visitEachChild(sourceFile);
            }
        
        
        Severity: Minor
        Found in packages/compiler/src/transform/log-unknown-transform-visitor.ts - About 6 hrs to fix

          File get-wasm-module-function.ts has 400 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * This file includes a single statement, the function declaration of the getWasmModuleFactory. This function is used in the
           * speedyjs-transformer to generate the code to load the wasm module.
           * The code is inspired by https://github.com/kripken/emscripten/blob/incoming/src/runtime.js
           */

            CodeGenerationDiagnostics has 37 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class CodeGenerationDiagnostics {
                static toDiagnostic(error: CodeGenerationDiagnostic): ts.Diagnostic {
                    const message = error.code === 0 ? `${error.message}\n${error.stack}` : error.message;
                    return {
                        code: error.code,
            Severity: Minor
            Found in packages/compiler/src/code-generation-diagnostic.ts - About 4 hrs to fix

              File binary-expression-code-generator.ts has 337 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import * as llvm from "llvm-node";
              import * as ts from "typescript";
              import {CodeGenerationDiagnostics} from "../../code-generation-diagnostic";
              import {CodeGenerationContext} from "../code-generation-context";
              import {SyntaxCodeGenerator} from "../syntax-code-generator";

                File array.spec.ts has 329 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                class Point {
                    x: number;
                    y: number;
                    constructor(x: number, y: number) {
                        this.x = x;
                Severity: Minor
                Found in packages/compiler/__integrationtests__/array.spec.ts - About 3 hrs to fix

                  File code-generation-diagnostic.ts has 329 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import * as ts from "typescript";
                  import * as util from "util";
                  
                  /**
                   * Error thrown during code generation. Has a node attach allowing to identify the source of the error.
                  Severity: Minor
                  Found in packages/compiler/src/code-generation-diagnostic.ts - About 3 hrs to fix

                    Function loadInstance has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function loadInstance(): Promise<WebAssemblyInstance> {
                            let instance: WebAssemblyInstance;
                    
                            let wasmLoaded: Promise<ArrayBuffer>;
                            // browser

                      Function exports has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports = function (config) {
                          config.set({
                      
                              // base path that will be used to resolve all patterns (eg. files, exclude)
                              basePath: "",
                      Severity: Major
                      Found in packages/compiler/karma.conf.js - About 3 hrs to fix

                        Function compileSourceCode has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function compileSourceCode(sourceCode: string, inputFileName: string, options?: UninitializedSpeedyJSCompilerOptions) {
                            const initializedOptions = getInitializedCompilerOptions(options);
                        
                            const defaultHost = ts.createCompilerHost(initializedOptions);
                        
                        
                        Severity: Major
                        Found in packages/compiler/src/in-memory-compiler.ts - About 3 hrs to fix

                          Scope has 24 functions (exceeds 20 allowed). Consider refactoring.
                          Open

                          export class Scope {
                              private variables = new Map<ts.Symbol, Value>();
                              private functions: Map<ts.Symbol, FunctionReference>;
                              private classes: Map<ts.Symbol, ClassReference>;
                              private returnAlloca: Allocation | undefined;
                          Severity: Minor
                          Found in packages/compiler/src/code-generation/scope.ts - About 2 hrs to fix

                            Function generate has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                            Open

                                generate(node: ts.PrefixUnaryExpression, context: CodeGenerationContext): Value {
                                    const left = context.generateValue(node.operand);
                                    const operandType = context.typeChecker.getTypeAtLocation(node.operand);
                                    const resultType = context.typeChecker.getTypeAtLocation(node);
                                    let result: llvm.Value | undefined;

                            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

                            File classes.spec.ts has 269 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            class DefaultInitializeClassWithAttributesOnly {
                                x: number;
                                y: number;
                            }
                            
                            
                            Severity: Minor
                            Found in packages/compiler/__integrationtests__/classes.spec.ts - About 2 hrs to fix

                              Function speedyJSLoader has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function speedyJSLoader(source) {
                                  const loader = this;
                              
                              
                                  const wasmFileWriter = {
                              Severity: Minor
                              Found in packages/loader/index.js - About 2 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 speedyJSLoader has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function speedyJSLoader(source) {
                                  const loader = this;
                              
                              
                                  const wasmFileWriter = {
                              Severity: Major
                              Found in packages/loader/index.js - About 2 hrs to fix

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

                                    generate(node: ts.PrefixUnaryExpression, context: CodeGenerationContext): Value {
                                        const left = context.generateValue(node.operand);
                                        const operandType = context.typeChecker.getTypeAtLocation(node.operand);
                                        const resultType = context.typeChecker.getTypeAtLocation(node);
                                        let result: llvm.Value | undefined;
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language