alsatian-test/alsatian

View on GitHub

Showing 15 of 54 total issues

Function loadTestFixtureInstance has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private loadTestFixtureInstance(
        testFixtureConstructor: new () => object,
        defaultFixtureDescription: string,
        filePath: string
    ): ITestFixture | null {
Severity: Major
Found in packages/alsatian/core/test-loader.ts - About 3 hrs to fix

    Function execute has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public static async execute(fileName: string, fixtureName: string, testName: string, range: Range, execArgv?: string[]) {
            if (styles[testName]) {
                styles[testName].dispose();
            }
    
    
    Severity: Minor
    Found in packages/vscode-extension/src/commands/run-test-command.ts - About 3 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 execute has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static async execute(fileName: string, fixtureName: string, testName: string, range: Range, execArgv?: string[]) {
            if (styles[testName]) {
                styles[testName].dispose();
            }
    
    
    Severity: Major
    Found in packages/vscode-extension/src/commands/run-test-command.ts - About 2 hrs to fix

      Function runTest has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public async runTest(fileName: string, fixtureName: string, testName?: string, execArgv?: string[]) {
      
              const eventData = {
                  fileName,
                  fixtureName,
      Severity: Major
      Found in packages/vscode-extension/src/running/test-runner.ts - About 2 hrs to fix

        Function subscription has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                const subscription = RunTestCommand.testRunner.subscribe(event => {
        
                    if (
                        event.payload.fileName !== fileName
                        || event.payload.fixtureName !== fixtureName
        Severity: Major
        Found in packages/vscode-extension/src/commands/run-test-command.ts - About 2 hrs to fix

          Function results has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  const results = await new Promise<ITestCompleteEvent[] | null>((resolve, reject) => {
                      let results = [] as ITestCompleteEvent[];
          
                      runProcess.on("message", message => {
                          if (message.type === "testComplete") {
          Severity: Minor
          Found in packages/vscode-extension/src/running/test-runner.ts - About 1 hr to fix

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

                public constructor(testSet: TestSet) {
                    if (testSet.testFixtures.length === 0) {
                        return;
                    }
            
            
            Severity: Minor
            Found in packages/alsatian/core/running/test-plan.ts - About 1 hr to fix

              Function findNearestFile has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function findNearestFile(fileName: string, directory?: string) {
                
                  if (!fileName) {
                      throw new TypeError("fileName is required.");
                  }
              Severity: Minor
              Found in packages/vscode-extension/src/find-nearest-file.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 errorMatches has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private errorMatches(
                      error: Error,
                      errorType: new (...args: Array<any>) => Error,
                      errorMessage: string
                  ) {
              Severity: Minor
              Found in packages/alsatian/core/matchers/function-matcher.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 checkObjectsAreDeepEqual has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  private checkObjectsAreDeepEqual(objectA: any, objectB: any): boolean {
                      // if one object is an array and the other is not then they are not equal
                      if (Array.isArray(objectA) !== Array.isArray(objectB)) {
                          return false;
                      }
              Severity: Minor
              Found in packages/alsatian/core/matchers/object-matcher.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 loadTestSets has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private async loadTestSets() {
              
                  const configs = await vscode.workspace.findFiles("**/.alsatianrc.json");
              
                  if (configs.length === 0) {

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

                    public constructor(public readonly type: new (...args: Array<any>) => ExpectedType) {
                        if (type === null || type === undefined) {
                            throw new TypeError("type must not be null or undefined");
                        }
                
                
                Severity: Minor
                Found in packages/alsatian/core/spying/type-matcher.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 match has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    private match(
                        countIsNotCorrect: (count: number) => boolean,
                        callCount: number,
                        callCountName: string,
                        callCountType: SpyCallCountType,
                Severity: Minor
                Found in packages/alsatian/core/matchers/function-spy-matcher.ts - About 35 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

                Avoid too many return statements within this function.
                Open

                      return "failure";

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

                  function GetTestCases(
                      caseArguments:
                          | (() => IterableIterator<any> | Array<Array<any>>)
                          | IterableIterator<any>
                          | Array<Array<any>>
                  Severity: Minor
                  Found in packages/alsatian/core/decorators/test-cases-decorator.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