Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,21 @@ export class ConfigurationManager {
* Gets the complexity status for a given complexity score.
*
* @param complexity - The complexity score to evaluate
* @param resource - Optional URI for workspace-specific configuration
* @param resourceOrConfig - Optional URI for workspace-specific configuration, or a pre-fetched config
* @returns Object containing status information
*/
public static getComplexityStatus(
complexity: number,
resource?: vscode.Uri
resourceOrConfig?: vscode.Uri | CodeMetricsConfig
): {
level: "low" | "warning" | "error";
icon: string;
text: string;
} {
const config = this.getConfiguration(resource);
const config =
resourceOrConfig instanceof vscode.Uri || resourceOrConfig === undefined
? this.getConfiguration(resourceOrConfig)
: resourceOrConfig;

if (complexity >= config.errorThreshold) {
return {
Expand Down
9 changes: 5 additions & 4 deletions src/providers/codeLensProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class MetricsCodeLensProvider implements vscode.CodeLensProvider {
functions.forEach((func) => {
// Only show code lens for functions with complexity > 0
if (func.complexity > 0) {
const codeLens = this.createCodeLens(func, document);
const codeLens = this.createCodeLens(func, document, config);
if (codeLens) {
codeLenses.push(codeLens);
}
Expand All @@ -146,18 +146,19 @@ export class MetricsCodeLensProvider implements vscode.CodeLensProvider {

private createCodeLens(
func: UnifiedFunctionMetrics,
document: vscode.TextDocument
document: vscode.TextDocument,
config: CodeMetricsConfig
): vscode.CodeLens | undefined {
const complexity = func.complexity;

// Create range for the code lens (above the function)
const line = func.startLine;
const range = new vscode.Range(line, 0, line, 0);

// Get status information using configuration manager
// Get status information using the already-resolved config
const status = ConfigurationManager.getComplexityStatus(
complexity,
document.uri
config
);

// Create the code lens title
Expand Down
Loading