Skip to content

Migrate data source from rules.json to messages.yaml #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 74 commits into from
Apr 23, 2025
Merged
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
4b904de
feat: Change Rule property for yaml
r0227n Mar 19, 2025
0a2c195
feat: Change information source from json to yaml
r0227n Mar 19, 2025
c3f612c
chor: Move convertToJsonFromYaml method into getRules method
r0227n Mar 19, 2025
755424d
fix: Add dependencies and remove ignore
r0227n Mar 21, 2025
032279a
fix: state and categories no longer output non-existent values.
r0227n Mar 21, 2025
17c63a1
chore: Minimized roop processing
r0227n Mar 24, 2025
25b02fd
add: convertToJsonFromYaml method test code
r0227n Mar 25, 2025
a4a2a98
refactor: simplify convertToJsonFromYaml method and optimize YAML map…
blendthink Mar 31, 2025
cf2a1ea
feat: add toJson extension method to YamlMap to simplify YAML map to …
blendthink Mar 31, 2025
2e51eff
fix: add exception handling for non-YamlMap entry values and improve …
blendthink Mar 31, 2025
67c16ff
test: add unit tests for YamlMap's toJson method
blendthink Mar 31, 2025
3e1ee91
refactor: remove convertToJsonFromYaml method and directly convert YA…
blendthink Mar 31, 2025
4ee2737
fix: typo ( exsistsCategories → existsCategories )
blendthink Mar 31, 2025
67b2bde
docs: add example YAML data to explain shared rule categories
blendthink Mar 31, 2025
aead3af
refactor: rename variable to better reflect its purpose
blendthink Mar 31, 2025
9188e2c
docs: add comment explaining rule addition conditions
blendthink Apr 1, 2025
d1be457
add: Create DTO for LintCode
r0227n Apr 1, 2025
6341baa
refactor: Changed to separate processing by presence/absence of Share…
r0227n Apr 1, 2025
e6214a1
refactor: Sort output results alphabetically
r0227n Apr 2, 2025
30a0f50
chore: Chnage details property to non null
r0227n Apr 2, 2025
21adaa6
refactor: Improve null safety and readability of sharedName processing
blendthink Apr 8, 2025
9bb0f31
refactor: Improve variable names to clarify type information and grou…
blendthink Apr 8, 2025
1517d2e
refactor: Improve variable names representing grouped LintCodeDto to …
blendthink Apr 8, 2025
d826011
refactor: Replace firstWhere with map and nonNulls to enhance null sa…
blendthink Apr 9, 2025
5c8c20f
refactor: Change variable names to plural to clarify that they repres…
blendthink Apr 9, 2025
dc9a41f
refactor: Add null checks and error handling for required fields
blendthink Apr 9, 2025
2b4c91e
refactor: Add processing for DTOs without sharedName and strengthen n…
blendthink Apr 9, 2025
80d88af
refactor: Store rule merging process in allRules variable to improve …
blendthink Apr 9, 2025
1685344
refactor: Change to call toList() after sorting
blendthink Apr 9, 2025
e8770c9
docs: Add comments to each processing step to clarify code flow
blendthink Apr 9, 2025
ee2373f
Refactor variable names for consistency
blendthink Apr 9, 2025
5e468a9
Remove unnecessary toList() conversion
blendthink Apr 9, 2025
b78e7bd
fix: Change AsyncMemoizer type from Iterable to List for consistency …
r0227n Apr 9, 2025
cb7abb6
chore: delete canConvertToRule method
r0227n Apr 9, 2025
65985e2
feat: implement LintCodeDtoMapper for converting LintCodeDto to Rule
r0227n Apr 9, 2025
7fc017e
fix: filter LintCodeDtos by canConvertToRule in groupedLintCodeDtosBy…
r0227n Apr 9, 2025
cf148f2
fix: correct property name check in toRuleFromDtos method
r0227n Apr 10, 2025
a2b0a81
test: add unit tests for LintCodeDtoMapper methods
r0227n Apr 10, 2025
5e06864
fix: lint warning for unnecessary_non_null_assertion
r0227n Apr 10, 2025
c256789
fix: change return type of getRules method to List<Rule>
r0227n Apr 10, 2025
871862b
fix: format
r0227n Apr 10, 2025
b0db03a
refactor: extract grouping and filtering logic for LintCodeDto to Lin…
r0227n Apr 10, 2025
2895b6c
delete: canConvertToRule
r0227n Apr 10, 2025
c32423f
refactor: delegate rule conversion logic to LintCodeDtoMapper
r0227n Apr 10, 2025
388411b
test: update state assertions in LintCodeDtoMapper tests
r0227n Apr 10, 2025
64d2fa9
refactor: simplify mapping of LintCodeDto to Rule in toRules method
r0227n Apr 10, 2025
9ada809
chore: Cancel the modifications made in 0a2c195f5d6bec090a35d8fb294e6…
r0227n Apr 14, 2025
2edc37d
chore ; LintCodeDto grouping process is no longer a function cutout.
r0227n Apr 14, 2025
39dea49
fix shared DTOs grouping logic to handle partial data
r0227n Apr 14, 2025
9bce333
refacotr: Delete toRuleFromDtos and merge toRule
r0227n Apr 14, 2025
da2e1fc
chore: Remove the where condition “state is only active”.
r0227n Apr 15, 2025
1ccc1c2
fix: Fixed to consider active/inactive and determine if version supports
r0227n Apr 15, 2025
c8191bc
chore: Fix the where condition because some values have no properties…
r0227n Apr 15, 2025
de3e1ec
chore: Move ExtState to a file defined by State
r0227n Apr 15, 2025
7711233
add: visibleForTesting annotation
r0227n Apr 15, 2025
2bd92cc
fix: Fix tests as mapper class is modified.
r0227n Apr 15, 2025
535e765
chore: remove incorrect visibleForTesting annotation
r0227n Apr 15, 2025
7d0b4f9
fix: The condition sharedName is null and state is not null does not …
r0227n Apr 15, 2025
763e64c
refactor: Rewrote method to directly assign parameters and create Rul…
r0227n Apr 15, 2025
ff06585
rename: Rename mapper class & method
r0227n Apr 16, 2025
7f37d0f
chore: Modified test cases due to function argument changes
r0227n Apr 16, 2025
a7c019a
chore: Support for renaming staging leaks
r0227n Apr 16, 2025
973b4a1
add: Correction of forgetting to add required
r0227n Apr 16, 2025
8ff0798
chore: The “categories ? []” in the comments for the reason.
r0227n Apr 16, 2025
3fc666a
chore: Corrected test description
r0227n Apr 17, 2025
18ad3cf
chore: rename comment
r0227n Apr 17, 2025
c9b9fa1
chore: Fixed default values are assigned when categories is null.
r0227n Apr 17, 2025
a067364
remove: Remove test case that throws when categories is null.
r0227n Apr 17, 2025
54d9340
remove: Remove the test case “DTO removes elements with categories an…
r0227n Apr 17, 2025
e943f45
chore: major version up :3.1.0 -> 4.0.0
r0227n Apr 17, 2025
29892cb
fix: Fixed to be able to judge even in a mixed active/inactive state.
r0227n Apr 18, 2025
9ed9b39
add: Add _isNotFlutterOnlyRules to unreachable_from_main
r0227n Apr 18, 2025
b88cb62
add: “Add Status” and “Remove incompatibles” to CHANGELOG
r0227n Apr 22, 2025
ab33133
edit: Move Status changes to a smaller level
r0227n Apr 22, 2025
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
Prev Previous commit
Next Next commit
chore ; LintCodeDto grouping process is no longer a function cutout.
r0227n committed Apr 14, 2025
commit 2edc37dbfd08b52d8451d637aad2873fccddabec
56 changes: 20 additions & 36 deletions tools/update_lint_rules/lib/src/mappers/lint_code_dto_mapper.dart
Original file line number Diff line number Diff line change
@@ -5,36 +5,6 @@ import 'package:update_lint_rules/src/models/lint_rule.dart';
class LintCodeDtoMapper {
const LintCodeDtoMapper._();

// Group DTOs by sharedName
static Map<String, List<LintCodeDto>> groupLintCodeDtosBySharedName(
List<LintCodeDto> dtos,
) {
return dtos
.where(
(dto) =>
dto.sharedName != null &&
dto.categories != null &&
dto.deprecatedDetails != null &&
dto.state != null,
)
// If `dto.sharedName` is not null, `dto.name` is the same as `dto.sharedName`.
// So, group by `dto.name`.
.groupListsBy((dto) => dto.name);
}

/// Filter [LintCodeDto] by sharedName
static Iterable<LintCodeDto> filterLintCodeDtosBySharedName(
Iterable<LintCodeDto> dtos,
) {
return dtos.where(
(dto) =>
dto.sharedName == null &&
dto.categories != null &&
dto.deprecatedDetails != null &&
dto.state != null,
);
}

/// Convert [LintCodeDto] to [Rule]
static Rule toRule(LintCodeDto dto) {
final categories = dto.categories;
@@ -93,19 +63,33 @@ class LintCodeDtoMapper {
/// Convert a list of [LintCodeDto] to a list of [Rule]
static List<Rule> toRules(Iterable<LintCodeDto> dtos) {
// Group DTOs by sharedName
final groupedLintCodeDtosBySharedName =
LintCodeDtoMapper.groupLintCodeDtosBySharedName(dtos.toList());
final groupedLintCodeDtosBySharedName = dtos
.where(
(dto) =>
dto.sharedName != null &&
dto.categories != null &&
dto.deprecatedDetails != null &&
dto.state != null,
)
// If `dto.sharedName` is not null, `dto.name` is the same as `dto.sharedName`.
// So, group by `dto.name`.
.groupListsBy((dto) => dto.name);

// Convert DTOs with sharedName to Rules
final rulesWithSharedName = groupedLintCodeDtosBySharedName.entries.map(
(e) => LintCodeDtoMapper.toRuleFromDtos(sharedName: e.key, dtos: e.value),
);

// Convert DTOs without sharedName to Rules
final rulesWithoutSharedName =
LintCodeDtoMapper.filterLintCodeDtosBySharedName(
dtos,
).map((d) => LintCodeDtoMapper.toRule(d));
final rulesWithoutSharedName = dtos
.where(
(dto) =>
dto.sharedName == null &&
dto.categories != null &&
dto.deprecatedDetails != null &&
dto.state != null,
)
.map((dto) => LintCodeDtoMapper.toRule(dto));

final allRules = [...rulesWithSharedName, ...rulesWithoutSharedName];