jbenden/vscode-c-cpp-flylint

View on GitHub
server/src/server.ts

Summary

Maintainability
D
1 day
Test Coverage
A
100%

Function validateTextDocument has 128 lines of code (exceeds 50 allowed). Consider refactoring.
Open

async function validateTextDocument(textDocument: TextDocument, force: boolean) {
    const tracker: ErrorMessageTracker = new ErrorMessageTracker();
    const fileUri: URI = URI.parse(textDocument.uri);
    const filePath: string = fileUri.fsPath;
    const normalizedFilePath = sysPath(path.normalize(filePath as string));
Severity: Major
Found in server/src/server.ts - About 4 hrs to fix

    File server.ts has 521 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    // Copyright (c) 2017-2022 The VSCode C/C++ Flylint Authors
    //
    // SPDX-License-Identifier: MIT
    
    import {
    Severity: Major
    Found in server/src/server.ts - About 2 hrs to fix

      Function getCppProperties has 69 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      export async function getCppProperties(cCppPropertiesPath: string, currentSettings: GlobalSettings, workspaceRoot: string) {
          try {
              if (fs.existsSync(cCppPropertiesPath)) {
                  const matchOn: string = await getActiveConfigurationName(currentSettings[FLYLINT_ID]);
                  const cCppProperties: IConfigurations = JSON5.parse(fs.readFileSync(cCppPropertiesPath, 'utf8'));
      Severity: Major
      Found in server/src/server.ts - About 1 hr to fix

        Function validateTextDocument has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring.
        Open

        async function validateTextDocument(textDocument: TextDocument, force: boolean) {
            const tracker: ErrorMessageTracker = new ErrorMessageTracker();
            const fileUri: URI = URI.parse(textDocument.uri);
            const filePath: string = fileUri.fsPath;
            const normalizedFilePath = sysPath(path.normalize(filePath as string));
        Severity: Minor
        Found in server/src/server.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

        Avoid deeply nested control flow statements.
        Open

                                                if (path.normalize(currentFilePath).startsWith(normalizedExcludedPath)) {
                                                    // it did; so do not accept diagnostics from this file.
                                                    acceptFile = false;
                                                }
        Severity: Major
        Found in server/src/server.ts - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                                  if (!path.isAbsolute(normalizedExcludedPath)) {
                                                      // prepend the workspace path and renormalize the path.
                                                      normalizedExcludedPath = path.normalize(path.join(workspaceRoot!, normalizedExcludedPath));
                                                  }
          Severity: Major
          Found in server/src/server.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                                if (currentSettings[FLYLINT_ID].debug) {
                                                    // eslint-disable-next-line no-console
                                                    console.log('Adding system path: ' + currentFilePath);
                                                }
            Severity: Major
            Found in server/src/server.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                                      if (currentSettings[FLYLINT_ID].debug) {
                                                          // eslint-disable-next-line no-console
                                                          console.log('Exclude Path: ' + excludedPath + '  VALUE: ' + substExcludedPath.value + '  Normalized: ' + normalizedExcludedPath);
                                                      }
              Severity: Major
              Found in server/src/server.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                                    if (acceptFile) {
                                                        if (currentSettings[FLYLINT_ID].debug) {
                                                            // eslint-disable-next-line no-console
                                                            console.log('Adding path: ' + currentFilePath);
                                                        }
                Severity: Major
                Found in server/src/server.ts - About 45 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return;
                  Severity: Major
                  Found in server/src/server.ts - About 30 mins to fix

                    FIXME found
                    Open

                    // FIXME: 1500 should be a configurable property!
                    Severity: Minor
                    Found in server/src/server.ts by fixme

                    There are no issues that match your filters.

                    Category
                    Status