Skip to content

Commit c22a8aa

Browse files
solid-illiaaihistovIllia Aihistov
andauthored
refactor: update automatic documentation generation (#315)
* feat: handle docs parser structured parameters * feat: implement macro and template support in documentation parser and update parameter metadata * docs: update documentation and examples for analysis_server_plugin migration * refactor: move and modularize documentation parsing utilities and improve rule parsing logic * fix: handle null field types in parameters parser and refine macro circular dependency detection logic * refactor: enhance documentation error reporting by including source context and specific field names * refactor: use toSource for type parsing and improve file name suffix extraction logic * refactor: extract parser extensions and optimize AST navigation and comment processing logic * refactor: extract file reading logic into FileUtils and modernize ParserUtils implementation --------- Co-authored-by: Illia Aihistov <illia.aihistov-us@solid.software>
1 parent 9567254 commit c22a8aa

37 files changed

Lines changed: 4985 additions & 656 deletions

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ dev_dependencies:
1919
solid_lints: <INSERT LATEST VERSION>
2020
```
2121
22-
And then include `solid_lints` into your project top-level `analysis_options.yaml`:
22+
Enable the plugin and include `solid_lints` in your project's top-level `analysis_options.yaml`:
2323

2424
```yaml
2525
include: package:solid_lints/analysis_options.yaml
26+
27+
plugins:
28+
solid_lints:
2629
```
2730

28-
Also you can use a specialized rule set designed for Dart tests.
31+
Also, you can use a specialized rule set designed for Dart tests.
2932
Add an `analysis_options.yaml` file under the `test/` directory, and include the ruleset:
3033

3134
```yaml
@@ -36,7 +39,18 @@ Then you can see suggestions in your IDE or you can run checks manually:
3639

3740
```bash
3841
dart analyze;
39-
dart run custom_lint;
42+
```
43+
44+
# Configuration
45+
46+
You can customize individual rule settings in your `analysis_options.yaml` under the `solid_lints` configuration block:
47+
48+
```yaml
49+
solid_lints:
50+
diagnostics:
51+
cyclomatic_complexity:
52+
max_complexity: 10
53+
avoid_non_null_assertion: true
4054
```
4155

4256
# Badge

doc/docusaurus/docs/1_rulesets/test.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ Given the quite large threshold configured for this metric we considered extract
6565

6666
Both options didn't look right, so we decided that tests are ok to be long.
6767

68+
## cyclomatic_complexity
69+
70+
State: **Disabled**.
71+
72+
Since we're not using the `function_lines_of_code` rule, the `main()` function in tests can have high cyclomatic complexity. For the rationale against splitting up `main()` in tests, see the comments for `function_lines_of_code` above.
73+
6874
## prefer_match_file_name
6975

7076
State: **Disabled**.

doc/docusaurus/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"typecheck": "tsc"
1717
},
1818
"dependencies": {
19-
"@docusaurus/core": "^3.1.0",
20-
"@docusaurus/preset-classic": "^3.1.0",
19+
"@docusaurus/core": "^3.10.1",
20+
"@docusaurus/preset-classic": "^3.10.1",
2121
"@easyops-cn/docusaurus-search-local": "^0.40.1",
2222
"@mdx-js/react": "^3.0.0",
2323
"clsx": "^2.1.0",

doc/docusaurus/yarn.lock

Lines changed: 4365 additions & 359 deletions
Large diffs are not rendered by default.

example/analysis_options.yaml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
include: package:solid_lints/analysis_options.yaml
22

3-
analyzer:
4-
plugins:
5-
- custom_lint
3+
plugins:
4+
solid_lints:
65

7-
custom_lint:
8-
rules:
9-
- cyclomatic_complexity:
6+
solid_lints:
7+
diagnostics:
8+
cyclomatic_complexity:
109
max_complexity: 4
11-
- number_of_parameters:
10+
number_of_parameters:
1211
max_parameters: 2
13-
- function_lines_of_code:
12+
function_lines_of_code:
1413
max_lines: 50
15-
- avoid_non_null_assertion
16-
- avoid_late_keyword
17-
- avoid_global_state
18-
- avoid_returning_widgets
19-
- avoid_unnecessary_setstate
20-
- double_literal_format
21-
- avoid_unnecessary_type_assertions
22-
- avoid_debug_print_in_release
23-
- avoid_using_api:
14+
avoid_non_null_assertion: true
15+
avoid_late_keyword: true
16+
avoid_global_state: true
17+
avoid_returning_widgets: true
18+
avoid_unnecessary_setstate: true
19+
double_literal_format: true
20+
avoid_unnecessary_type_assertions: true
21+
avoid_debug_print_in_release: true
22+
avoid_using_api:
2423
severity: info
2524
entries:
2625
- class_name: Future

example/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dependencies:
1010
sdk: flutter
1111

1212
dev_dependencies:
13-
custom_lint: ^0.8.1
1413
solid_lints:
1514
path: ../
1615
test: ^1.25.14

lib/analysis_options.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
analyzer:
2-
plugins:
3-
- custom_lint
42
exclude:
53
# General generated files
64
- "**/*.g.dart"

lib/src/common/parameters/excluded_annotations_list_parameter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import 'package:analyzer/dart/ast/ast.dart';
33
/// A parameter model representing excluded annotations for linting.
44
/// It defines class-level annotations that indicate when class members
55
/// should be ignored during analysis.
6+
///
7+
/// @docType String | List<String>
68
class ExcludedAnnotationsListParameter {
79
/// The set of excluded annotation names.
810
final Set<String> excludedAnnotations;

lib/src/common/parameters/excluded_entities_list_parameter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import 'package:analyzer/dart/ast/ast.dart';
88
/// - extension
99
/// - extension_type
1010
/// - enum
11+
///
12+
/// @docType String | List<String>
1113
class ExcludedEntitiesListParameter {
1214
/// The parameter model
1315
final Set<String> excludedEntityNames;

lib/src/common/parameters/excluded_identifiers_list_parameter.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:solid_lints/src/common/parameters/excluded_identifier_parameter.
44

55
/// A model representing "exclude" parameters for linting, defining
66
/// identifiers (classes, methods, functions) to be ignored during analysis.
7+
///
8+
/// @docType String | Map | List<String | Map>
79
class ExcludedIdentifiersListParameter {
810
/// A list of identifiers (classes, methods, functions) that should be
911
/// excluded from the lint.

0 commit comments

Comments
 (0)