server/src/server.ts
Function validateTextDocument
has 128 lines of code (exceeds 50 allowed). Consider refactoring. Open
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));
File server.ts
has 521 lines of code (exceeds 500 allowed). Consider refactoring. Open
Open
// Copyright (c) 2017-2022 The VSCode C/C++ Flylint Authors
//
// SPDX-License-Identifier: MIT
import {
Function getCppProperties
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
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 validateTextDocument
has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring. Open
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
Avoid deeply nested control flow statements. Open
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
Open
if (!path.isAbsolute(normalizedExcludedPath)) {
// prepend the workspace path and renormalize the path.
normalizedExcludedPath = path.normalize(path.join(workspaceRoot!, normalizedExcludedPath));
}
Avoid deeply nested control flow statements. Open
Open
if (currentSettings[FLYLINT_ID].debug) {
// eslint-disable-next-line no-console
console.log('Adding system path: ' + currentFilePath);
}
Avoid deeply nested control flow statements. Open
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
Open
if (acceptFile) {
if (currentSettings[FLYLINT_ID].debug) {
// eslint-disable-next-line no-console
console.log('Adding path: ' + currentFilePath);
}
Avoid too many return
statements within this function. Open
Open
return;
FIXME found Open
Open
// FIXME: 1500 should be a configurable property!
- Exclude checks