@aiready/consistency 0.21.4 → 0.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -820,6 +820,7 @@ async function analyzeNamingGeneralized(files) {
820
820
  if (!spec || spec === "*" || spec === "default") continue;
821
821
  if (exceptions.has(spec)) continue;
822
822
  if (COMMON_ABBREVIATIONS.has(spec.toLowerCase())) continue;
823
+ if (spec.includes(".")) continue;
823
824
  if (!conventions.variablePattern.test(spec) && !conventions.classPattern.test(spec) && (!conventions.constantPattern || !conventions.constantPattern.test(spec)) && (!conventions.typePattern || !conventions.typePattern.test(spec)) && (!conventions.interfacePattern || !conventions.interfacePattern.test(spec)) && !/^[A-Z][A-Z0-9_]*$/.test(spec)) {
824
825
  issues.push({
825
826
  type: "naming-inconsistency",
@@ -1030,7 +1031,8 @@ async function analyzeConsistency(options) {
1030
1031
  }
1031
1032
  for (const issue of patternIssues) {
1032
1033
  if (!shouldIncludeSeverity(issue.severity, minSeverity)) continue;
1033
- const fileName = issue.fileName || issue.file || issue.filePath || (Array.isArray(issue.files) ? issue.files[0] : "unknown");
1034
+ const anyIssue = issue;
1035
+ const fileName = anyIssue.fileName || anyIssue.file || anyIssue.filePath || (Array.isArray(issue.files) ? issue.files[0] : "unknown");
1034
1036
  if (!fileIssuesMap.has(fileName)) fileIssuesMap.set(fileName, []);
1035
1037
  fileIssuesMap.get(fileName).push(issue);
1036
1038
  }
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  analyzeConsistency
4
- } from "./chunk-ZG3KFSD3.mjs";
4
+ } from "./chunk-7DKVZNY7.mjs";
5
5
 
6
6
  // src/cli.ts
7
7
  import { Command } from "commander";
package/dist/index.js CHANGED
@@ -839,6 +839,7 @@ async function analyzeNamingGeneralized(files) {
839
839
  if (!spec || spec === "*" || spec === "default") continue;
840
840
  if (exceptions.has(spec)) continue;
841
841
  if (COMMON_ABBREVIATIONS.has(spec.toLowerCase())) continue;
842
+ if (spec.includes(".")) continue;
842
843
  if (!conventions.variablePattern.test(spec) && !conventions.classPattern.test(spec) && (!conventions.constantPattern || !conventions.constantPattern.test(spec)) && (!conventions.typePattern || !conventions.typePattern.test(spec)) && (!conventions.interfacePattern || !conventions.interfacePattern.test(spec)) && !/^[A-Z][A-Z0-9_]*$/.test(spec)) {
843
844
  issues.push({
844
845
  type: "naming-inconsistency",
@@ -1049,7 +1050,8 @@ async function analyzeConsistency(options) {
1049
1050
  }
1050
1051
  for (const issue of patternIssues) {
1051
1052
  if (!shouldIncludeSeverity(issue.severity, minSeverity)) continue;
1052
- const fileName = issue.fileName || issue.file || issue.filePath || (Array.isArray(issue.files) ? issue.files[0] : "unknown");
1053
+ const anyIssue = issue;
1054
+ const fileName = anyIssue.fileName || anyIssue.file || anyIssue.filePath || (Array.isArray(issue.files) ? issue.files[0] : "unknown");
1053
1055
  if (!fileIssuesMap.has(fileName)) fileIssuesMap.set(fileName, []);
1054
1056
  fileIssuesMap.get(fileName).push(issue);
1055
1057
  }
@@ -1187,7 +1189,7 @@ var ConsistencyProvider = (0, import_core7.createProvider)({
1187
1189
  return calculateConsistencyScore(
1188
1190
  allIssues,
1189
1191
  totalFiles,
1190
- options.costConfig
1192
+ options?.costConfig
1191
1193
  );
1192
1194
  }
1193
1195
  });
package/dist/index.mjs CHANGED
@@ -6,16 +6,13 @@ import {
6
6
  analyzePatterns,
7
7
  calculateConsistencyScore,
8
8
  detectNamingConventions
9
- } from "./chunk-ZG3KFSD3.mjs";
9
+ } from "./chunk-7DKVZNY7.mjs";
10
10
 
11
11
  // src/index.ts
12
12
  import { ToolRegistry } from "@aiready/core";
13
13
 
14
14
  // src/provider.ts
15
- import {
16
- createProvider,
17
- ToolName
18
- } from "@aiready/core";
15
+ import { createProvider, ToolName } from "@aiready/core";
19
16
  var ConsistencyProvider = createProvider({
20
17
  id: ToolName.NamingConsistency,
21
18
  alias: ["consistency", "naming", "standards"],
@@ -39,7 +36,7 @@ var ConsistencyProvider = createProvider({
39
36
  return calculateConsistencyScore(
40
37
  allIssues,
41
38
  totalFiles,
42
- options.costConfig
39
+ options?.costConfig
43
40
  );
44
41
  }
45
42
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/consistency",
3
- "version": "0.21.4",
3
+ "version": "0.21.6",
4
4
  "description": "Detects consistency issues in naming, patterns, and architecture that confuse AI models",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -43,7 +43,7 @@
43
43
  "@typescript-eslint/typescript-estree": "^8.53.0",
44
44
  "chalk": "^5.3.0",
45
45
  "commander": "^14.0.0",
46
- "@aiready/core": "0.24.4"
46
+ "@aiready/core": "0.24.6"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "^24.0.0",
@@ -0,0 +1,64 @@
1
+ import { describe, it, expect, beforeAll, afterAll } from 'vitest';
2
+ import { analyzeNamingGeneralized } from '../analyzers/naming-generalized';
3
+ import { join } from 'path';
4
+ import { writeFileSync, mkdirSync, rmSync } from 'fs';
5
+ import { tmpdir } from 'os';
6
+
7
+ describe('Naming Analysis - Dotted Identifiers', () => {
8
+ const tmpDir = join(tmpdir(), 'aiready-consistency-dotted-tests');
9
+
10
+ beforeAll(() => {
11
+ mkdirSync(tmpDir, { recursive: true });
12
+ });
13
+
14
+ afterAll(() => {
15
+ rmSync(tmpDir, { recursive: true, force: true });
16
+ });
17
+
18
+ function createTestFile(name: string, content: string): string {
19
+ const filePath = join(tmpDir, name);
20
+ writeFileSync(filePath, content, 'utf8');
21
+ return filePath;
22
+ }
23
+
24
+ it('should NOT flag dotted identifiers in Python imports', async () => {
25
+ const file = createTestFile(
26
+ 'library_test.py',
27
+ `
28
+ import urllib.parse
29
+ import pytrends.request
30
+
31
+ def analyze():
32
+ pass
33
+ `
34
+ );
35
+
36
+ const issues = await analyzeNamingGeneralized([file]);
37
+
38
+ // urllib.parse and pytrends.request should be ignored because they contain dots
39
+ const namingIssues = issues.filter(
40
+ (i) => i.type === 'naming-inconsistency'
41
+ );
42
+ expect(namingIssues.length).toBe(0);
43
+ });
44
+
45
+ it('should still flag inconsistent top-level names without dots', async () => {
46
+ const file = createTestFile(
47
+ 'bad_naming.py',
48
+ `
49
+ def BadNamingConvention():
50
+ pass
51
+
52
+ user_Name = "John"
53
+ `
54
+ );
55
+
56
+ const issues = await analyzeNamingGeneralized([file]);
57
+ const namingIssues = issues.filter(
58
+ (i) => i.type === 'naming-inconsistency'
59
+ );
60
+
61
+ // BadNamingConvention (PascalCase for function) and user_Name (MixedCase) should be flagged
62
+ expect(namingIssues.length).toBeGreaterThanOrEqual(1);
63
+ });
64
+ });
package/src/analyzer.ts CHANGED
@@ -41,7 +41,22 @@ export async function analyzeConsistency(
41
41
  const filePaths = await scanFiles(scanOptions);
42
42
 
43
43
  // Collect issues by category
44
- let namingIssues: any[] = [];
44
+ let namingIssues: Array<{
45
+ fileName?: string;
46
+ file?: string;
47
+ filePath?: string;
48
+ line?: number;
49
+ column?: number;
50
+ identifier?: string;
51
+ type?: string;
52
+ severity: Severity;
53
+ message?: string;
54
+ suggestion?: string;
55
+ description?: string;
56
+ files?: string[];
57
+ examples?: string[];
58
+ location?: { file: string; line: number; column: number };
59
+ }> = [];
45
60
  if (checkNaming) {
46
61
  // 1. Generalized naming analysis for all supported files
47
62
  namingIssues = await analyzeNamingGeneralized(filePaths);
@@ -66,10 +81,7 @@ export async function analyzeConsistency(
66
81
  if (!shouldIncludeSeverity(issue.severity, minSeverity)) continue;
67
82
 
68
83
  const fileName =
69
- (issue as any).fileName ||
70
- (issue as any).file ||
71
- (issue as any).filePath ||
72
- 'unknown';
84
+ issue.fileName || issue.file || issue.filePath || 'unknown';
73
85
  if (!fileIssuesMap.has(fileName)) fileIssuesMap.set(fileName, []);
74
86
  fileIssuesMap.get(fileName)!.push(issue as unknown as ConsistencyIssue);
75
87
  }
@@ -78,13 +90,12 @@ export async function analyzeConsistency(
78
90
  for (const issue of patternIssues) {
79
91
  if (!shouldIncludeSeverity(issue.severity, minSeverity)) continue;
80
92
 
93
+ const anyIssue = issue as any;
81
94
  const fileName =
82
- (issue as any).fileName ||
83
- (issue as any).file ||
84
- (issue as any).filePath ||
85
- (Array.isArray((issue as any).files)
86
- ? (issue as any).files[0]
87
- : 'unknown');
95
+ (anyIssue.fileName as string) ||
96
+ (anyIssue.file as string) ||
97
+ (anyIssue.filePath as string) ||
98
+ (Array.isArray(issue.files) ? (issue.files[0] as string) : 'unknown');
88
99
  if (!fileIssuesMap.has(fileName)) fileIssuesMap.set(fileName, []);
89
100
  fileIssuesMap.get(fileName)!.push(issue as unknown as ConsistencyIssue);
90
101
  }
@@ -147,6 +147,7 @@ export async function analyzeNamingGeneralized(
147
147
  if (!spec || spec === '*' || spec === 'default') continue;
148
148
  if (exceptions.has(spec)) continue;
149
149
  if (COMMON_ABBREVIATIONS.has(spec.toLowerCase())) continue;
150
+ if (spec.includes('.')) continue; // Library imports like urllib.parse (Issue: Library Naming Inconsistency)
150
151
 
151
152
  if (
152
153
  !conventions.variablePattern.test(spec) &&
package/src/cli.ts CHANGED
@@ -91,7 +91,7 @@ EXAMPLES:
91
91
  checkNaming: options.naming !== false && mergedConfig.checkNaming,
92
92
  checkPatterns: options.patterns !== false && mergedConfig.checkPatterns,
93
93
  checkArchitecture: options.architecture || mergedConfig.checkArchitecture,
94
- minSeverity: (options.minSeverity as any) || mergedConfig.minSeverity,
94
+ minSeverity: (options.minSeverity as string) || mergedConfig.minSeverity,
95
95
  include: options.include?.split(',') || mergedConfig.include,
96
96
  exclude: options.exclude?.split(',') || mergedConfig.exclude,
97
97
  };
package/src/provider.ts CHANGED
@@ -1,9 +1,4 @@
1
- import {
2
- AnalysisResult,
3
- createProvider,
4
- ToolName,
5
- ScanOptions,
6
- } from '@aiready/core';
1
+ import { createProvider, ToolName, ScanOptions } from '@aiready/core';
7
2
  import { analyzeConsistency } from './analyzer';
8
3
  import { calculateConsistencyScore } from './scoring';
9
4
  import { ConsistencyOptions, ConsistencyIssue } from './types';
@@ -20,22 +15,22 @@ export const ConsistencyProvider = createProvider({
20
15
  return analyzeConsistency(options as ConsistencyOptions);
21
16
  },
22
17
  getResults(report) {
23
- return report.results as AnalysisResult[];
18
+ return report.results;
24
19
  },
25
20
  getSummary(report) {
26
21
  return report.summary;
27
22
  },
28
23
  score(output, options) {
29
- const results = (output.results || []) as AnalysisResult[];
24
+ const results = output.results || [];
30
25
  const allIssues = results.flatMap(
31
- (r) => (r.issues || []) as ConsistencyIssue[]
32
- );
33
- const totalFiles = (output.summary as any)?.filesAnalyzed || results.length;
26
+ (r) => r.issues || []
27
+ ) as ConsistencyIssue[];
28
+ const totalFiles = output.summary?.filesAnalyzed || results.length;
34
29
 
35
30
  return calculateConsistencyScore(
36
31
  allIssues,
37
32
  totalFiles,
38
- (options as any).costConfig
33
+ options?.costConfig
39
34
  );
40
35
  },
41
36
  });
@@ -50,7 +50,7 @@ export function traverseAST(
50
50
 
51
51
  // Visit children
52
52
  for (const key of Object.keys(node)) {
53
- const value = (node as any)[key];
53
+ const value = (node as unknown as Record<string, unknown>)[key];
54
54
 
55
55
  if (Array.isArray(value)) {
56
56
  for (const child of value) {