jbenden/vscode-c-cpp-flylint

View on GitHub

Showing 28 of 83 total issues

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 workspaceRoot: string = await getWorkspaceRoot(textDocument.uri);
Severity: Major
Found in server/src/server.ts - About 4 hrs to fix

    Linter has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Linter {
        protected name: string;
        protected settings: Settings;
        protected workspaceRoot: string;
        protected enabled: boolean;
    Severity: Minor
    Found in server/src/linters/linter.ts - About 2 hrs to fix

      File server.ts has 526 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 validateTextDocument has a Cognitive Complexity of 29 (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 workspaceRoot: string = await getWorkspaceRoot(textDocument.uri);
        Severity: Minor
        Found in server/src/server.ts - 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 formatTestSummary has a Cognitive Complexity of 28 (exceeds 15 allowed). Consider refactoring.
        Open

        Severity: Minor
        Found in specs/debug-console/logger.ts - 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 buildCommandLine has 84 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

            protected buildCommandLine(fileName: string, tmpFileName: string): string[] {
                let includePathParams = this.getIncludePathParams();
                let languageParam = this.getLanguageParam();
                let iquoteParams: string[];
        
        
        Severity: Major
        Found in server/src/linters/clang.ts - About 2 hrs to fix

          Function getCppProperties has 76 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 JSON5 = require('json5');
          Severity: Major
          Found in server/src/server.ts - About 2 hrs to fix

            Function startLSClient has 61 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            function startLSClient(serverOptions: ServerOptions, context: ExtensionContext) {
                // Options to control the language client.
                const clientOptions: LanguageClientOptions = {
                    // Register the server for C/C++ documents.
                    documentSelector: [{ scheme: 'file', language: 'c' }, { scheme: 'file', language: 'cpp' }],
            Severity: Major
            Found in client/src/extension.ts - About 1 hr to fix

              Function parseLine has 58 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

                  protected parseLine(line: string): InternalDiagnostic | null {
                      let regex = /^(([^ ]+)?\s\s([0-9]+)\s([0-9]+\s)?\s([iI]nfo|[wW]arning|[eE]rror|[nN]ote|[sS]upplemental)\s([0-9]+):\s(.*)|(.+?):([0-9]+):([0-9]+:)?\s([iI]nfo|[wW]arning|[eE]rror|[nN]ote|[sS]upplemental)\s([0-9]+):\s(.*))$/;
                      let regexArray: RegExpExecArray | null;
              
                      let excludeRegex = /^(\s+file '.*'|[^ \t]+|)$/;
              Severity: Major
              Found in server/src/linters/pclintplus.ts - About 1 hr to fix

                Function injectMockFileSystem has 53 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                export function injectMockFileSystem() {
                    beforeEach(() => {
                        mock({
                            '.clang_complete': 'text content',
                
                
                Severity: Major
                Found in specs/mock-fs.ts - About 1 hr to fix

                  Function formatSnapshotMessage has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
                  Open

                  Severity: Minor
                  Found in specs/debug-console/logger.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

                  Avoid deeply nested control flow statements.
                  Open

                                                      if (acceptFile) {
                                                          // Windows drive letter must be prefixed with a slash
                                                          if (currentFilePath[0] !== '/') {
                                                              currentFilePath = '/' + currentFilePath;
                                                          }
                  Severity: Major
                  Found in server/src/server.ts - About 45 mins to fix

                    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 (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 (!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 (currentFilePath[0] !== '/') {
                                                                    currentFilePath = '/' + currentFilePath;
                                                                }
                            Severity: Major
                            Found in server/src/server.ts - About 45 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return {
                                              parseError: 'Line could not be parsed: ' + line,
                                              fileName: '',
                                              line: 0,
                                              column: 0,
                              Severity: Major
                              Found in server/src/linters/clang.ts - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                Severity: Major
                                Found in specs/debug-console/logger.ts - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                  Severity: Major
                                  Found in specs/debug-console/logger.ts - About 30 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language