Showing 27 of 79 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 normalizedFilePath = sysPath(path.normalize(filePath as string));
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;
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 {
Function formatTestSummary
has a Cognitive Complexity of 28 (exceeds 15 allowed). Consider refactoring. Open
function formatTestSummary(text: string): string {
if (!text.includes('\n')) {
return '';
}
- Read upRead up
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[];
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'));
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' }],
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));
- Read upRead up
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 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 '.*'|PC-lint.*|licensed.*|LICENSED.*|.*evaluation license.*|[^ \t]+|)$/;
Function injectMockFileSystem
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
export function injectMockFileSystem() {
beforeEach(() => {
mock({
'.clang_complete': 'text content',
Avoid deeply nested control flow statements. Open
if (currentSettings[FLYLINT_ID].debug) {
// eslint-disable-next-line no-console
console.log('Adding system path: ' + currentFilePath);
}
Function formatSnapshotMessage
has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring. Open
function formatSnapshotMessage(text: string): string {
if (text.endsWith('updated.') || text.endsWith('written.') || text.endsWith('removed.')) {
return bold(green(text));
}
- Read upRead up
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 (currentSettings[FLYLINT_ID].debug) {
// eslint-disable-next-line no-console
console.log('Exclude Path: ' + excludedPath + ' VALUE: ' + substExcludedPath.value + ' Normalized: ' + normalizedExcludedPath);
}
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;
}
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);
}
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));
}
Avoid too many return
statements within this function. Open
return formatSnapshotSummary(text, 'written', green);
Avoid too many return
statements within this function. Open
return {
parseError: 'Line could not be parsed: ' + line,
fileName: '',
line: 0,
column: 0,
Avoid too many return
statements within this function. Open
return `${formatSnapshotSummary(text, 'failed', red)} ${darkGray(
'Inspect your code changes or re-run jest with `JEST_RUNNER_UPDATE_SNAPSHOTS=true` to update them.'
)}`;
Avoid too many return
statements within this function. Open
return;