MichaReiser/speedy.js

View on GitHub

Showing 322 of 322 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        it("returns the int remainder", async (cb) => {
            expect(await intRemainder(5, 3)).toBe(5 % 3);
            expect(await intRemainder(5, -3)).toBe(5 % -3);
            expect(await intRemainder(-5, 3)).toBe(-5 % 3);
            expect(await intRemainder(-5, -3)).toBe(-5 % -3);
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 824..830

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

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 4 locations. Consider refactoring.
Open

    describe("^", () => {
        it("performs a binary xor on an int", async (cb) => {
            expect(await binXorInts(10, 16)).toBe(10 ^ 16);
            cb();
        });
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 581..592
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 621..632
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 641..652

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

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 4 locations. Consider refactoring.
Open

    describe(">>>", () => {
        it("performs a right shift and fills the bits on the left with zero on an int", async (cb) => {
            expect(await binZeroFillRightShiftInts(10, 16)).toBe(10 >>> 16);
            cb();
        });
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 581..592
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 601..612
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 641..652

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

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 4 locations. Consider refactoring.
Open

    describe("<<", () => {
        it("performs a left shift on an int", async (cb) => {
            expect(await binLeftShiftInt(10, 16)).toBe(10 << 16);
            cb();
        });
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 581..592
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 601..612
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 621..632

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

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 4 locations. Consider refactoring.
Open

    describe("&", () => {
        it("performs a binary and on an int", async (cb) => {
            expect(await binAndInts(10, 16)).toBe(10 & 16);
            cb();
        });
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 601..612
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 621..632
packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 641..652

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

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

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

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        describe("**", () => {
            it("computes the power of an int to the base of an int", async (cb) => {
                const result = await powInts(5, 3);
                expect(result).toBe(5 ** 3);
                cb();
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 412..424
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 438..450
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 464..476

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

    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 4 locations. Consider refactoring.
    Open

        describe("*", () => {
            it("multiplies two ints", async (cb) => {
                const result = await multiplyInts(10, 7);
                expect(result).toBe(10 * 7);
                cb();
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 412..424
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 464..476
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 490..502

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

    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 4 locations. Consider refactoring.
    Open

        describe("-", () => {
            it("subtracts two ints", async (cb) => {
                const result = await subtractInts(10, 7);
                expect(result).toBe(10 - 7);
                cb();
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 438..450
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 464..476
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 490..502

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

    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 4 locations. Consider refactoring.
    Open

        describe("/", () => {
            it("divides two ints", async (cb) => {
                const result = await divideInts(70, 7);
                expect(result).toBe(70 / 7);
                cb();
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 412..424
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 438..450
    packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 490..502

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

    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 3 locations. Consider refactoring.
    Open

                case ts.SyntaxKind.GreaterThanGreaterThanEqualsToken: {
                    const leftInt = Primitive.toInt32(context.generateValue(binaryExpression.left), leftType, resultType, context).generateIR();
                    const rightInt = Primitive.toInt32(context.generateValue(binaryExpression.right), rightType, resultType, context).generateIR();
    
                    // mask not needed, less than 32 guaranteed by wasm
    packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 260..268
    packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 312..320

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

    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 3 locations. Consider refactoring.
    Open

                case ts.SyntaxKind.GreaterThanGreaterThanGreaterThanToken: {
                    const leftInt = Primitive.toInt32(context.generateValue(binaryExpression.left), leftType, resultType, context).generateIR();
                    const rightInt = Primitive.toInt32(context.generateValue(binaryExpression.right), rightType, resultType, context).generateIR();
    
                    // mask not needed, less than 32 guaranteed by wasm
    packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 248..256
    packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 312..320

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

    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 3 locations. Consider refactoring.
    Open

                case ts.SyntaxKind.LessThanLessThanEqualsToken: {
                    const leftInt = Primitive.toInt32(context.generateValue(binaryExpression.left), leftType, resultType, context).generateIR();
                    const rightInt = Primitive.toInt32(context.generateValue(binaryExpression.right), rightType, resultType, context).generateIR();
    
                    // mask not needed, less than 32 guaranteed by wasm
    packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 248..256
    packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 260..268

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

    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

    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";

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                  case ts.SyntaxKind.CaretToken: {
                      const leftInt = Primitive.toInt32(context.generateValue(binaryExpression.left), leftType, resultType, context).generateIR();
                      const rightInt = Primitive.toInt32(context.generateValue(binaryExpression.right), rightType, resultType, context).generateIR();
      
                      result = context.builder.createXor(leftInt, rightInt, "xor");
      packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 45..51

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

      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

                  case ts.SyntaxKind.AmpersandEqualsToken: {
                      const leftInt = Primitive.toInt32(context.generateValue(binaryExpression.left), leftType, resultType, context).generateIR();
                      const rightInt = Primitive.toInt32(context.generateValue(binaryExpression.right), rightType, resultType, context).generateIR();
      
                      result = context.builder.createAnd(leftInt, rightInt, "and");
      packages/compiler/src/code-generation/code-generators/binary-expression-code-generator.ts on lines 155..162

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

      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

      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

            Similar blocks of code found in 3 locations. Consider refactoring.
            Open

                describe("+=", () => {
                    it("adds x to y and returns the sum of the two integers", async function(cb) {
                        expect(await addEqualsInts(3, 4)).toBe(3 + 4);
                        cb();
                    });
            packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 426..436
            packages/compiler/__integrationtests__/binary-expression.spec.ts on lines 452..462

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

            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

            Severity
            Category
            Status
            Source
            Language