MichaReiser/speedy.js

View on GitHub

Showing 100 of 322 total issues

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

function build() {
    if (!fs.existsSync(TOOLS_DIRECTORY)) {
        fs.mkdirSync(TOOLS_DIRECTORY);
    }

Severity: Minor
Found in packages/runtime/scripts/install-dependencies.js - About 1 hr to fix

    Function from has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            static from(native: any[], elementType: string, types: Types, objectReferences: Map<object, int>): RuntimeArray {
                // begin, back, capacity
                const size = PTR_SIZE * 2 + sizeOf("i32");
                const arrayPtr = malloc(size);
                const elementSize = sizeOf(elementType);

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

          generate(ifStatement: ts.IfStatement, context: CodeGenerationContext): void {
              const fun = context.scope.enclosingFunction;
              let thenBlock = llvm.BasicBlock.create(context.llvmContext, "if.then");
              let elseBlock = llvm.BasicBlock.create(context.llvmContext, "if.else");
              const end = llvm.BasicBlock.create(context.llvmContext, "if.end");

        Function createTransformer has 26 lines of code (exceeds 25 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 1 hr to fix

          Function emit has 26 lines of code (exceeds 25 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 1 hr to fix

            Function createResolvedFunction has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function createResolvedFunction(name: string,
                                                   typeParameters: ts.Type[],
                                                   parameters: ResolvedFunctionParameter[],
                                                   returnType: ts.Type,
                                                   sourceFile?: ts.SourceFile,
            Severity: Major
            Found in packages/compiler/src/code-generation/value/resolved-function.ts - About 1 hr to fix

              Function isSpeedyJSFunction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export function isSpeedyJSFunction(fun: ts.FunctionLikeDeclaration) {
                  if (!fun.body || !isBlock(fun.body)) {
                      return false;
                  }
              
              
              Severity: Minor
              Found in packages/compiler/src/util/speedyjs-function.ts - About 55 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 visitIdentifier has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  visitIdentifier(identifier: ts.Identifier, context: TransformVisitorContext) {
                      const symbol = this.compilationContext.typeChecker.getSymbolAtLocation(identifier);
              
                      if (typeof symbol !== "undefined" && symbol.flags & (ts.SymbolFlags.Function | ts.SymbolFlags.Method | ts.SymbolFlags.Constructor)) {
                          for (const declaration of symbol.getDeclarations() as ts.FunctionLikeDeclaration[]) {
              Severity: Minor
              Found in packages/compiler/src/transform/speedyjs-transform-visitor.ts - About 55 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 serializedTypeName has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              function serializedTypeName(type: ts.Type, typeChecker: TypeChecker): string {
                  if (isMaybeObjectType(type)) {
                      type = type.getNonNullableType();
                  }
              
              

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

                  value(this: CodeGenerationContext, value: llvm.Value, type: ts.Type): Value {
                      const symbol = type.getSymbol();
              
                      if (type.flags & (ts.TypeFlags.BooleanLike | ts.TypeFlags.NumberLike | ts.TypeFlags.IntLike)) {
                          return new Primitive(value, type);
              Severity: Minor
              Found in packages/compiler/src/code-generation/code-generation-context-mixin.ts - About 55 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 getCallArguments has a Cognitive Complexity of 9 (exceeds 5 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];

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

                  private getObjectFilesToLink(objectFiles: string[], entrySymbols: string[]) {
                      let loopAgain = true;
                      const includedObjectFiles = new Set<string>();
                      const unresolvedSymbols = new Set<string>(entrySymbols);
              
              
              Severity: Minor
              Found in packages/compiler/src/external-tools/llvm-link.ts - About 55 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 arraySpliceInsertingNewElements has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              async function arraySpliceInsertingNewElements(array: int[], start: int, deleteCount: int, a: int, b: int, c: int, d: int) {
              Severity: Major
              Found in packages/compiler/__integrationtests__/array.spec.ts - About 50 mins to fix

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

                    generate(identifier: ts.Identifier, context: CodeGenerationContext): Value {
                        let symbol = context.typeChecker.getSymbolAtLocation(identifier);
                
                        if (symbol.flags & ts.SymbolFlags.Alias) {
                            symbol = context.typeChecker.getAliasedSymbol(symbol);

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

                function toLiteral(value: any): ts.Expression {
                    if (Array.isArray(value)) {
                        return ts.createArrayLiteral(value.map(element => toLiteral(element)));
                    } else if (typeof value === "object") {
                        if (value.kind && value.flags) { // ts node

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

                export function compileSourceCode(sourceCode: string, inputFileName: string, options?: UninitializedSpeedyJSCompilerOptions) {
                    const initializedOptions = getInitializedCompilerOptions(options);
                
                    const defaultHost = ts.createCompilerHost(initializedOptions);
                
                
                Severity: Minor
                Found in packages/compiler/src/in-memory-compiler.ts - About 45 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 generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    generate(postfixUnaryExpression: ts.PostfixUnaryExpression, context: CodeGenerationContext): Value {
                        const left = context.generateValue(postfixUnaryExpression.operand);
                        const before = left.generateIR(context);
                        let updated: llvm.Value | undefined;
                        const operandType = context.typeChecker.getTypeAtLocation(postfixUnaryExpression.operand);

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

                async function forBreakToLabel() {
                    "use speedyjs";
                
                    let result = 0;
                    loop1:
                Severity: Minor
                Found in packages/compiler/__integrationtests__/for-statement.spec.ts - About 45 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 ifElseIfElse has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                async function ifElseIfElse(condition: boolean, ifValue: number, elseIfCondition: boolean, elseIfValue: number, elseValue: number) {
                Severity: Minor
                Found in packages/compiler/__integrationtests__/if-statement.spec.ts - About 35 mins to fix

                  Function makeSourceMap has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function makeSourceMap(sourceMapText, outputText, filePath, contents, loader) {
                  Severity: Minor
                  Found in packages/loader/index.js - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language