@angular-modernizer/plugin-solid 1.0.0 → 1.1.0

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.
Files changed (28) hide show
  1. package/README.md +34 -48
  2. package/dist/index.d.ts +15 -4
  3. package/dist/index.js +14 -3
  4. package/dist/orchestrators/god-switch-transform-orchestrator.d.ts +3 -14
  5. package/dist/orchestrators/god-switch-transform-orchestrator.js +1 -13
  6. package/dist/orchestrators/service-dip-violation-transform.orchestrator.d.ts +38 -24
  7. package/dist/orchestrators/service-dip-violation-transform.orchestrator.js +28 -24
  8. package/dist/rules/dip-violation.rule.d.ts +14 -17
  9. package/dist/rules/dip-violation.rule.js +16 -19
  10. package/dist/rules/god-switch-analysis.rule.d.ts +13 -26
  11. package/dist/rules/god-switch-analysis.rule.js +15 -28
  12. package/dist/rules/isp-violation.rule.d.ts +12 -17
  13. package/dist/rules/isp-violation.rule.js +14 -19
  14. package/dist/rules/lsp-violation.rule.d.ts +15 -21
  15. package/dist/rules/lsp-violation.rule.js +17 -23
  16. package/dist/rules/ocp-violation.rule.d.ts +9 -18
  17. package/dist/rules/ocp-violation.rule.js +11 -20
  18. package/dist/rules/service-dip-violation.analysis.rule.d.ts +28 -19
  19. package/dist/rules/service-dip-violation.analysis.rule.js +13 -20
  20. package/dist/rules/srp-violation.rule.d.ts +19 -29
  21. package/dist/rules/srp-violation.rule.js +21 -31
  22. package/dist/solid-plugin.d.ts +3 -14
  23. package/dist/solid-plugin.js +3 -14
  24. package/dist/transform-rules/god-switch-transform.rule.d.ts +0 -3
  25. package/dist/transform-rules/god-switch-transform.rule.js +0 -3
  26. package/dist/transform-rules/service-dip-violation.transform.rule.d.ts +0 -3
  27. package/dist/transform-rules/service-dip-violation.transform.rule.js +0 -3
  28. package/package.json +5 -11
@@ -1,30 +1,25 @@
1
+ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
1
2
  /**
2
- * @angular-modernizer/plugin-solid - ISP Violation Rule
3
- *
4
- * Detects violations of the Interface Segregation Principle.
5
- * Identifies interfaces with too many methods or mixed responsibilities.
3
+ * ISP Violation Rule (`solid:isp-violation`) - detects Interface Segregation
4
+ * Principle violations.
6
5
  *
7
- * Detection Patterns:
8
- * - Interfaces with more than X methods (configurable threshold)
9
- * - Interfaces that mix different concerns (UI, Data, Business logic)
10
- * - Classes implementing interfaces they don't fully use
11
- *
12
- * This rule helps ensure interfaces are focused and clients don't depend on methods they don't use.
6
+ * Detection patterns (`violationType` in the metadata):
7
+ * - `too-many-methods`: interfaces with more than 5 methods
8
+ * - `mixed-concerns`: interfaces whose members mix concerns (UI, data,
9
+ * business logic) by name keywords
10
+ * - `too-many-interfaces`: classes implementing more than 3 interfaces
11
+ * - `unused-interface-methods`: classes that implement an interface but
12
+ * declare no methods
13
13
  *
14
14
  * @example
15
+ * ```typescript
15
16
  * // Violation: interface forces implementations to define unrelated methods
16
17
  * interface IWorker {
17
18
  * work(): void;
18
19
  * eat(): void; // Irrelevant for robots
19
20
  * sleep(): void; // Irrelevant for robots
20
21
  * }
21
- */
22
- import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
23
- /**
24
- * ISP Violation Rule - detects Interface Segregation Principle violations.
25
- *
26
- * This rule implements the Interface Segregation Principle by detecting
27
- * interfaces that are too large or have mixed responsibilities.
22
+ * ```
28
23
  */
29
24
  export declare class ISPViolationRule implements AnalysisRule {
30
25
  readonly id = "solid:isp-violation";
@@ -1,33 +1,28 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ISPViolationRule = void 0;
4
+ const ts_morph_1 = require("ts-morph");
2
5
  /**
3
- * @angular-modernizer/plugin-solid - ISP Violation Rule
6
+ * ISP Violation Rule (`solid:isp-violation`) - detects Interface Segregation
7
+ * Principle violations.
4
8
  *
5
- * Detects violations of the Interface Segregation Principle.
6
- * Identifies interfaces with too many methods or mixed responsibilities.
7
- *
8
- * Detection Patterns:
9
- * - Interfaces with more than X methods (configurable threshold)
10
- * - Interfaces that mix different concerns (UI, Data, Business logic)
11
- * - Classes implementing interfaces they don't fully use
12
- *
13
- * This rule helps ensure interfaces are focused and clients don't depend on methods they don't use.
9
+ * Detection patterns (`violationType` in the metadata):
10
+ * - `too-many-methods`: interfaces with more than 5 methods
11
+ * - `mixed-concerns`: interfaces whose members mix concerns (UI, data,
12
+ * business logic) by name keywords
13
+ * - `too-many-interfaces`: classes implementing more than 3 interfaces
14
+ * - `unused-interface-methods`: classes that implement an interface but
15
+ * declare no methods
14
16
  *
15
17
  * @example
18
+ * ```typescript
16
19
  * // Violation: interface forces implementations to define unrelated methods
17
20
  * interface IWorker {
18
21
  * work(): void;
19
22
  * eat(): void; // Irrelevant for robots
20
23
  * sleep(): void; // Irrelevant for robots
21
24
  * }
22
- */
23
- Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.ISPViolationRule = void 0;
25
- const ts_morph_1 = require("ts-morph");
26
- /**
27
- * ISP Violation Rule - detects Interface Segregation Principle violations.
28
- *
29
- * This rule implements the Interface Segregation Principle by detecting
30
- * interfaces that are too large or have mixed responsibilities.
25
+ * ```
31
26
  */
32
27
  class ISPViolationRule {
33
28
  id = 'solid:isp-violation';
@@ -1,33 +1,27 @@
1
+ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
1
2
  /**
2
- * @angular-modernizer/plugin-solid - Liskov Substitution Principle Rule
3
- *
4
- * Detects classes that violate the Liskov Substitution Principle (LSP)
5
- * by not being substitutable for their base types without changing program correctness.
3
+ * LSP Violation Rule (`solid:lsp-violation`) - detects Liskov Substitution
4
+ * Principle violations that break substitutability.
6
5
  *
7
- * Detection Patterns:
8
- * - Classes that don't implement all abstract methods from base classes
9
- * - Methods that override base methods with incompatible signatures
10
- * - Properties that change type incompatibly in derived classes
11
- * - Missing interface implementations (excluding Angular internal properties starting with ɵ)
12
- * - instanceof checks that indicate poor inheritance design
13
- * - Abstract method implementations that throw exceptions or behave unexpectedly
14
- *
15
- * This rule helps ensure proper inheritance hierarchies and interface compliance.
16
- * Note: Angular internal properties (starting with ɵ) are automatically ignored.
6
+ * Detection patterns (`violationType` in the metadata):
7
+ * - `missing-interface-method`, `missing-interface-property`: members of an
8
+ * implemented interface that the class does not declare (Angular internal
9
+ * members starting with `ɵ` are ignored)
10
+ * - `missing-abstract-method`: abstract methods of the base class that are
11
+ * not implemented
12
+ * - `throws-not-implemented`: implementations of abstract methods whose
13
+ * first `throw` mentions `NotImplemented` or `not implemented`
14
+ * - `instanceof-check`, `excessive-instanceof-checks`: `instanceof` checks in
15
+ * methods (3 or more in one method count as excessive)
17
16
  *
18
17
  * @example
18
+ * ```typescript
19
19
  * // Violation: derived class weakens base contract
20
20
  * class Bird { fly(): void {} }
21
21
  * class Penguin extends Bird {
22
22
  * fly(): void { throw new Error('Penguins cannot fly'); }
23
23
  * }
24
- */
25
- import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
26
- /**
27
- * LSP Violation Rule - detects Liskov Substitution Principle violations.
28
- *
29
- * This rule implements the Liskov Substitution Principle by detecting
30
- * inheritance and interface implementation issues that break substitutability.
24
+ * ```
31
25
  */
32
26
  export declare class LSPViolationRule implements AnalysisRule {
33
27
  readonly id = "solid:lsp-violation";
@@ -1,36 +1,30 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LSPViolationRule = void 0;
4
+ const ts_morph_1 = require("ts-morph");
2
5
  /**
3
- * @angular-modernizer/plugin-solid - Liskov Substitution Principle Rule
6
+ * LSP Violation Rule (`solid:lsp-violation`) - detects Liskov Substitution
7
+ * Principle violations that break substitutability.
4
8
  *
5
- * Detects classes that violate the Liskov Substitution Principle (LSP)
6
- * by not being substitutable for their base types without changing program correctness.
7
- *
8
- * Detection Patterns:
9
- * - Classes that don't implement all abstract methods from base classes
10
- * - Methods that override base methods with incompatible signatures
11
- * - Properties that change type incompatibly in derived classes
12
- * - Missing interface implementations (excluding Angular internal properties starting with ɵ)
13
- * - instanceof checks that indicate poor inheritance design
14
- * - Abstract method implementations that throw exceptions or behave unexpectedly
15
- *
16
- * This rule helps ensure proper inheritance hierarchies and interface compliance.
17
- * Note: Angular internal properties (starting with ɵ) are automatically ignored.
9
+ * Detection patterns (`violationType` in the metadata):
10
+ * - `missing-interface-method`, `missing-interface-property`: members of an
11
+ * implemented interface that the class does not declare (Angular internal
12
+ * members starting with `ɵ` are ignored)
13
+ * - `missing-abstract-method`: abstract methods of the base class that are
14
+ * not implemented
15
+ * - `throws-not-implemented`: implementations of abstract methods whose
16
+ * first `throw` mentions `NotImplemented` or `not implemented`
17
+ * - `instanceof-check`, `excessive-instanceof-checks`: `instanceof` checks in
18
+ * methods (3 or more in one method count as excessive)
18
19
  *
19
20
  * @example
21
+ * ```typescript
20
22
  * // Violation: derived class weakens base contract
21
23
  * class Bird { fly(): void {} }
22
24
  * class Penguin extends Bird {
23
25
  * fly(): void { throw new Error('Penguins cannot fly'); }
24
26
  * }
25
- */
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.LSPViolationRule = void 0;
28
- const ts_morph_1 = require("ts-morph");
29
- /**
30
- * LSP Violation Rule - detects Liskov Substitution Principle violations.
31
- *
32
- * This rule implements the Liskov Substitution Principle by detecting
33
- * inheritance and interface implementation issues that break substitutability.
27
+ * ```
34
28
  */
35
29
  class LSPViolationRule {
36
30
  id = 'solid:lsp-violation';
@@ -1,18 +1,15 @@
1
+ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
1
2
  /**
2
- * @angular-modernizer/plugin-solid - Open/Closed Principle Rule
3
- *
4
- * Detects classes that violate the Open/Closed Principle (OCP)
5
- * by being closed for extension but requiring modification for new features.
3
+ * OCP Violation Rule (`solid:ocp-violation`) - detects code that has to be
4
+ * modified for new features (Open/Closed Principle violation).
6
5
  *
7
- * Detection Patterns:
8
- * - Switch statements with many cases (> 5)
9
- * - Long if-else chains (> 4 conditions)
10
- * - Methods with too many parameters (> 4)
11
- * - Classes with hard dependencies on concrete implementations
12
- *
13
- * This rule helps enforce extensible code architecture.
6
+ * Detection patterns in class methods (`violationType` in the metadata):
7
+ * - `large-switch-statement`: switch statements with more than 5 cases
8
+ * - `long-if-else-chain`: if/else chains with more than 4 branches
9
+ * - `too-many-parameters`: methods with more than 4 parameters
14
10
  *
15
11
  * @example
12
+ * ```typescript
16
13
  * // Violation: requires modification for each new shape type
17
14
  * function createShape(type: string) {
18
15
  * switch (type) {
@@ -21,13 +18,7 @@
21
18
  * // Every new shape requires editing this function
22
19
  * }
23
20
  * }
24
- */
25
- import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
26
- /**
27
- * OCP Violation Rule - detects Open/Closed Principle violations.
28
- *
29
- * This rule implements the Open/Closed Principle by detecting
30
- * code that is closed for extension and requires modification for new features.
21
+ * ```
31
22
  */
32
23
  export declare class OCPViolationRule implements AnalysisRule {
33
24
  readonly id = "solid:ocp-violation";
@@ -1,19 +1,18 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OCPViolationRule = void 0;
4
+ const ts_morph_1 = require("ts-morph");
2
5
  /**
3
- * @angular-modernizer/plugin-solid - Open/Closed Principle Rule
6
+ * OCP Violation Rule (`solid:ocp-violation`) - detects code that has to be
7
+ * modified for new features (Open/Closed Principle violation).
4
8
  *
5
- * Detects classes that violate the Open/Closed Principle (OCP)
6
- * by being closed for extension but requiring modification for new features.
7
- *
8
- * Detection Patterns:
9
- * - Switch statements with many cases (> 5)
10
- * - Long if-else chains (> 4 conditions)
11
- * - Methods with too many parameters (> 4)
12
- * - Classes with hard dependencies on concrete implementations
13
- *
14
- * This rule helps enforce extensible code architecture.
9
+ * Detection patterns in class methods (`violationType` in the metadata):
10
+ * - `large-switch-statement`: switch statements with more than 5 cases
11
+ * - `long-if-else-chain`: if/else chains with more than 4 branches
12
+ * - `too-many-parameters`: methods with more than 4 parameters
15
13
  *
16
14
  * @example
15
+ * ```typescript
17
16
  * // Violation: requires modification for each new shape type
18
17
  * function createShape(type: string) {
19
18
  * switch (type) {
@@ -22,15 +21,7 @@
22
21
  * // Every new shape requires editing this function
23
22
  * }
24
23
  * }
25
- */
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.OCPViolationRule = void 0;
28
- const ts_morph_1 = require("ts-morph");
29
- /**
30
- * OCP Violation Rule - detects Open/Closed Principle violations.
31
- *
32
- * This rule implements the Open/Closed Principle by detecting
33
- * code that is closed for extension and requires modification for new features.
24
+ * ```
34
25
  */
35
26
  class OCPViolationRule {
36
27
  id = 'solid:ocp-violation';
@@ -1,20 +1,7 @@
1
+ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
1
2
  /**
2
- * @angular-modernizer/plugin-solid - Service DIP Violation Rule
3
- *
4
- * Detects constructor injection of concrete `@Injectable` classes instead of interfaces
5
- * (Dependency Inversion Principle violation).
6
- *
7
- * Detection Pattern:
8
- * - `@Injectable` class whose constructor parameter type resolves to another `@Injectable` class
9
- * - Both the injecting class and the injected type must have `@Injectable`
10
- * - Optional: cross-layer detection via path-based layer extraction
11
- *
12
- * Sibling to DIPViolationRule (solid:dip-violation-direct-instantiation) which detects
13
- * `new MyService()` usage. This rule detects `constructor(private svc: ConcreteService)`.
14
- *
15
- * TransformRule + Orchestrator is deferred to v2.
3
+ * Options of {@link ServiceDipViolationRule}, passed to its constructor.
16
4
  */
17
- import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
18
5
  export interface ServiceDipViolationConfig {
19
6
  /**
20
7
  * When true, only report violations that cross architectural layer boundaries.
@@ -23,26 +10,47 @@ export interface ServiceDipViolationConfig {
23
10
  */
24
11
  crossLayerOnly?: boolean;
25
12
  }
13
+ /**
14
+ * Metadata of a {@link ServiceDipViolationRule} result.
15
+ */
26
16
  export interface ServiceDipViolationMetadata {
17
+ /** Always `concrete-injection`. */
27
18
  violationType: 'concrete-injection';
19
+ /** Concrete `@Injectable` class used as the parameter type. */
28
20
  injectedClass: string;
21
+ /** `@Injectable` class whose constructor injects it. */
29
22
  injectingClass: string;
23
+ /** Name of the constructor parameter. */
30
24
  parameterName: string;
25
+ /** Suggested interface name: `I` + injected class name. */
31
26
  suggestedInterfaceName: string;
27
+ /** Detection confidence (0..1); currently always 0.95. */
32
28
  confidence: number;
29
+ /** Reserved for mutual injection; currently always `false`. */
33
30
  isBidirectional: boolean;
31
+ /** Whether both layers are known and differ. */
34
32
  isCrossLayer: boolean;
33
+ /** Layer of the injecting file, when a known layer segment is in its path. */
35
34
  injectingLayer?: string;
35
+ /** Layer of the injected file, when a known layer segment is in its path. */
36
36
  injectedLayer?: string;
37
37
  }
38
38
  /**
39
- * Service DIP Violation Rule — detects concrete `@Injectable` constructor injection.
39
+ * Service DIP Violation Rule (`solid:service-dip-violation`) - detects
40
+ * concrete `@Injectable` constructor injection.
41
+ *
42
+ * Reports a constructor parameter of an `@Injectable` class whose type
43
+ * resolves (via the type checker, across files) to another `@Injectable`
44
+ * class, instead of an abstraction (interface). Provides a suggested
45
+ * interface name (`I` + injected class name) and a suggested fix. With
46
+ * {@link ServiceDipViolationConfig.crossLayerOnly}, only injections between
47
+ * different path-based layers are reported. Declaration files are skipped.
40
48
  *
41
- * Reports when an `@Injectable` class injects another `@Injectable` class directly instead
42
- * of depending on an abstraction (interface). Provides a suggested interface name
43
- * (`I` + injected class name) and a human-readable suggested fix.
49
+ * Sibling of {@link DIPViolationRule}, which detects `new MyService()`.
50
+ * {@link ServiceDipViolationTransformRule} applies the fix.
44
51
  *
45
52
  * @example
53
+ * ```typescript
46
54
  * // Violation detected:
47
55
  * class UserService {
48
56
  * constructor(private orderService: OrderService) {}
@@ -52,6 +60,7 @@ export interface ServiceDipViolationMetadata {
52
60
  * class UserService {
53
61
  * constructor(private orderService: IOrderService) {}
54
62
  * }
63
+ * ```
55
64
  */
56
65
  export declare class ServiceDipViolationRule implements AnalysisRule {
57
66
  readonly id = "solid:service-dip-violation";
@@ -1,31 +1,23 @@
1
1
  "use strict";
2
- /**
3
- * @angular-modernizer/plugin-solid - Service DIP Violation Rule
4
- *
5
- * Detects constructor injection of concrete `@Injectable` classes instead of interfaces
6
- * (Dependency Inversion Principle violation).
7
- *
8
- * Detection Pattern:
9
- * - `@Injectable` class whose constructor parameter type resolves to another `@Injectable` class
10
- * - Both the injecting class and the injected type must have `@Injectable`
11
- * - Optional: cross-layer detection via path-based layer extraction
12
- *
13
- * Sibling to DIPViolationRule (solid:dip-violation-direct-instantiation) which detects
14
- * `new MyService()` usage. This rule detects `constructor(private svc: ConcreteService)`.
15
- *
16
- * TransformRule + Orchestrator is deferred to v2.
17
- */
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.ServiceDipViolationRule = void 0;
20
4
  const ts_morph_1 = require("ts-morph");
21
5
  /**
22
- * Service DIP Violation Rule — detects concrete `@Injectable` constructor injection.
6
+ * Service DIP Violation Rule (`solid:service-dip-violation`) - detects
7
+ * concrete `@Injectable` constructor injection.
8
+ *
9
+ * Reports a constructor parameter of an `@Injectable` class whose type
10
+ * resolves (via the type checker, across files) to another `@Injectable`
11
+ * class, instead of an abstraction (interface). Provides a suggested
12
+ * interface name (`I` + injected class name) and a suggested fix. With
13
+ * {@link ServiceDipViolationConfig.crossLayerOnly}, only injections between
14
+ * different path-based layers are reported. Declaration files are skipped.
23
15
  *
24
- * Reports when an `@Injectable` class injects another `@Injectable` class directly instead
25
- * of depending on an abstraction (interface). Provides a suggested interface name
26
- * (`I` + injected class name) and a human-readable suggested fix.
16
+ * Sibling of {@link DIPViolationRule}, which detects `new MyService()`.
17
+ * {@link ServiceDipViolationTransformRule} applies the fix.
27
18
  *
28
19
  * @example
20
+ * ```typescript
29
21
  * // Violation detected:
30
22
  * class UserService {
31
23
  * constructor(private orderService: OrderService) {}
@@ -35,6 +27,7 @@ const ts_morph_1 = require("ts-morph");
35
27
  * class UserService {
36
28
  * constructor(private orderService: IOrderService) {}
37
29
  * }
30
+ * ```
38
31
  */
39
32
  class ServiceDipViolationRule {
40
33
  id = 'solid:service-dip-violation';
@@ -1,43 +1,33 @@
1
+ import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
1
2
  /**
2
- * @angular-modernizer/plugin-solid - SRP Violation Rule
3
- *
4
- * Detects Single Responsibility Principle violations in classes.
3
+ * SRP Violation Rule (`solid:srp-single-responsibility-violation`) - detects
4
+ * Single Responsibility Principle violations in classes.
5
5
  *
6
- * Detection Patterns:
7
- * - Classes with too many methods (configurable threshold, default: 15).
8
- * Get/set accessors and arrow-function / function-expression properties
9
- * count as methods.
10
- * - Classes mixing multiple responsibility categories
11
- * - Base classes (abstract, or extended by >= 3 classes in the project) with
12
- * a large public/protected surface: every subclass inherits all concerns,
13
- * so the category check already fires at 2 categories. Metadata carries
14
- * `isBaseClass`, `isAbstract` and `subclassCount`.
6
+ * Detection patterns (`violationType` in the metadata):
7
+ * - `too-many-methods`: classes with more than 15 callable members. Get/set
8
+ * accessors (a pair counts once) and arrow-function / function-expression
9
+ * properties count as methods.
10
+ * - `mixed-responsibilities`: member names that fall into 3 or more
11
+ * responsibility categories. Base classes (abstract, or extended by 3 or
12
+ * more classes in the project) with at least 8 public/protected callable
13
+ * members are flagged at 2 categories, since every subclass inherits all
14
+ * concerns; metadata then carries `isBaseClass`, `isAbstract` and
15
+ * `subclassCount`.
16
+ * - `single-method-multi-concern`: a method of 20 or more lines whose body
17
+ * touches 4 or more categories.
15
18
  *
16
- * Responsibility Categories:
17
- * - UI: render, display, show, hide, toggle, open, close
18
- * - Business: calculate, validate, process, transform, compute
19
- * - HTTP: fetch, get, post, put, delete, request, call
20
- * - Data: save, load, store, retrieve, persist, cache
21
- * - Event: emit, dispatch, trigger, fire, notify, publish
22
- * - Lifecycle: init, destroy, cleanup, setup, teardown
23
- *
24
- * This rule helps enforce the Single Responsibility Principle by identifying
25
- * classes that are doing too much or handling multiple unrelated concerns.
19
+ * Responsibility categories are matched by keywords: UI, Business, HTTP,
20
+ * Data, Event and Lifecycle.
26
21
  *
27
22
  * @example
23
+ * ```typescript
28
24
  * // Violation: class mixes HTTP, business, and UI concerns
29
25
  * class UserComponent {
30
26
  * fetchUsers() {} // HTTP concern
31
27
  * calculateTotal() {} // Business concern
32
28
  * renderChart() {} // UI concern
33
29
  * }
34
- */
35
- import type { AnalysisRule, AnalysisContext, AnalysisResult } from '@angular-modernizer/plugin-system';
36
- /**
37
- * SRP Violation Rule - detects Single Responsibility Principle violations.
38
- *
39
- * This rule implements the Single Responsibility Principle by detecting
40
- * classes with too many methods or mixed responsibilities.
30
+ * ```
41
31
  */
42
32
  export declare class SingleResponsibilityRule implements AnalysisRule {
43
33
  readonly id = "solid:srp-single-responsibility-violation";
@@ -1,46 +1,36 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SingleResponsibilityRule = void 0;
4
+ const ts_morph_1 = require("ts-morph");
2
5
  /**
3
- * @angular-modernizer/plugin-solid - SRP Violation Rule
6
+ * SRP Violation Rule (`solid:srp-single-responsibility-violation`) - detects
7
+ * Single Responsibility Principle violations in classes.
4
8
  *
5
- * Detects Single Responsibility Principle violations in classes.
9
+ * Detection patterns (`violationType` in the metadata):
10
+ * - `too-many-methods`: classes with more than 15 callable members. Get/set
11
+ * accessors (a pair counts once) and arrow-function / function-expression
12
+ * properties count as methods.
13
+ * - `mixed-responsibilities`: member names that fall into 3 or more
14
+ * responsibility categories. Base classes (abstract, or extended by 3 or
15
+ * more classes in the project) with at least 8 public/protected callable
16
+ * members are flagged at 2 categories, since every subclass inherits all
17
+ * concerns; metadata then carries `isBaseClass`, `isAbstract` and
18
+ * `subclassCount`.
19
+ * - `single-method-multi-concern`: a method of 20 or more lines whose body
20
+ * touches 4 or more categories.
6
21
  *
7
- * Detection Patterns:
8
- * - Classes with too many methods (configurable threshold, default: 15).
9
- * Get/set accessors and arrow-function / function-expression properties
10
- * count as methods.
11
- * - Classes mixing multiple responsibility categories
12
- * - Base classes (abstract, or extended by >= 3 classes in the project) with
13
- * a large public/protected surface: every subclass inherits all concerns,
14
- * so the category check already fires at 2 categories. Metadata carries
15
- * `isBaseClass`, `isAbstract` and `subclassCount`.
16
- *
17
- * Responsibility Categories:
18
- * - UI: render, display, show, hide, toggle, open, close
19
- * - Business: calculate, validate, process, transform, compute
20
- * - HTTP: fetch, get, post, put, delete, request, call
21
- * - Data: save, load, store, retrieve, persist, cache
22
- * - Event: emit, dispatch, trigger, fire, notify, publish
23
- * - Lifecycle: init, destroy, cleanup, setup, teardown
24
- *
25
- * This rule helps enforce the Single Responsibility Principle by identifying
26
- * classes that are doing too much or handling multiple unrelated concerns.
22
+ * Responsibility categories are matched by keywords: UI, Business, HTTP,
23
+ * Data, Event and Lifecycle.
27
24
  *
28
25
  * @example
26
+ * ```typescript
29
27
  * // Violation: class mixes HTTP, business, and UI concerns
30
28
  * class UserComponent {
31
29
  * fetchUsers() {} // HTTP concern
32
30
  * calculateTotal() {} // Business concern
33
31
  * renderChart() {} // UI concern
34
32
  * }
35
- */
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.SingleResponsibilityRule = void 0;
38
- const ts_morph_1 = require("ts-morph");
39
- /**
40
- * SRP Violation Rule - detects Single Responsibility Principle violations.
41
- *
42
- * This rule implements the Single Responsibility Principle by detecting
43
- * classes with too many methods or mixed responsibilities.
33
+ * ```
44
34
  */
45
35
  class SingleResponsibilityRule {
46
36
  id = 'solid:srp-single-responsibility-violation';
@@ -1,9 +1,3 @@
1
- /**
2
- * @angular-modernizer/plugin-solid - Main Plugin
3
- *
4
- * The main entry point for the SOLID principles analysis plugin.
5
- * Provides analysis rules for detecting SOLID principle violations.
6
- */
7
1
  import type { Plugin, AnalysisRule, TransformRule, ValidationRule, IKernel } from '@angular-modernizer/plugin-system';
8
2
  /**
9
3
  * SOLID Principles Analysis Plugin
@@ -13,7 +7,7 @@ import type { Plugin, AnalysisRule, TransformRule, ValidationRule, IKernel } fro
13
7
  * in Angular applications. It focuses on architectural issues that can lead to
14
8
  * maintainability problems.
15
9
  *
16
- * ## Current Rules
10
+ * ## Rules
17
11
  *
18
12
  * ### Analysis Rules
19
13
  * - {@link DIPViolationRule}: Detects direct service instantiation (DIP violation)
@@ -26,12 +20,7 @@ import type { Plugin, AnalysisRule, TransformRule, ValidationRule, IKernel } fro
26
20
  *
27
21
  * ### Transform Rules
28
22
  * - {@link GodSwitchTransformRule}: Transforms God Switch violations into Factory Pattern implementations
29
- *
30
- * ## Future Rules (Planned)
31
- *
32
- * - MissingInterfaceRule: Services without interfaces (DIP)
33
- * - CircularDependencyRule: Import cycles (architectural)
34
- * - FatInterfaceRule: Interfaces with too many methods (ISP)
23
+ * - {@link ServiceDipViolationTransformRule}: Replaces concrete constructor injection with an interface and an `InjectionToken`
35
24
  *
36
25
  * @see {@link DIPViolationRule} for the DIP implementation
37
26
  * @see {@link SingleResponsibilityRule} for the SRP implementation
@@ -43,7 +32,7 @@ export declare class SolidPlugin implements Plugin {
43
32
  */
44
33
  readonly name = "@angular-modernizer/plugin-solid";
45
34
  /**
46
- * Plugin version (from package.json).
35
+ * Plugin version reported to the kernel.
47
36
  */
48
37
  readonly version = "0.1.0";
49
38
  /**
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * @angular-modernizer/plugin-solid - Main Plugin
4
- *
5
- * The main entry point for the SOLID principles analysis plugin.
6
- * Provides analysis rules for detecting SOLID principle violations.
7
- */
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.SolidPlugin = void 0;
10
4
  const dip_violation_rule_js_1 = require("./rules/dip-violation.rule.js");
@@ -24,7 +18,7 @@ const service_dip_violation_analysis_rule_js_1 = require("./rules/service-dip-vi
24
18
  * in Angular applications. It focuses on architectural issues that can lead to
25
19
  * maintainability problems.
26
20
  *
27
- * ## Current Rules
21
+ * ## Rules
28
22
  *
29
23
  * ### Analysis Rules
30
24
  * - {@link DIPViolationRule}: Detects direct service instantiation (DIP violation)
@@ -37,12 +31,7 @@ const service_dip_violation_analysis_rule_js_1 = require("./rules/service-dip-vi
37
31
  *
38
32
  * ### Transform Rules
39
33
  * - {@link GodSwitchTransformRule}: Transforms God Switch violations into Factory Pattern implementations
40
- *
41
- * ## Future Rules (Planned)
42
- *
43
- * - MissingInterfaceRule: Services without interfaces (DIP)
44
- * - CircularDependencyRule: Import cycles (architectural)
45
- * - FatInterfaceRule: Interfaces with too many methods (ISP)
34
+ * - {@link ServiceDipViolationTransformRule}: Replaces concrete constructor injection with an interface and an `InjectionToken`
46
35
  *
47
36
  * @see {@link DIPViolationRule} for the DIP implementation
48
37
  * @see {@link SingleResponsibilityRule} for the SRP implementation
@@ -54,7 +43,7 @@ class SolidPlugin {
54
43
  */
55
44
  name = '@angular-modernizer/plugin-solid';
56
45
  /**
57
- * Plugin version (from package.json).
46
+ * Plugin version reported to the kernel.
58
47
  */
59
48
  version = '0.1.0';
60
49
  /**
@@ -1,6 +1,3 @@
1
- /**
2
- * @angular-modernizer/plugin-solid - God Switch Transform Rule
3
- */
4
1
  import type { TransformRule, TransformContext, TransformResult } from '@angular-modernizer/plugin-system';
5
2
  import type { PublicApi } from '@angular-modernizer/api';
6
3
  /**