Skip to content

Commit

Permalink
Release flint 2.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pante committed Aug 17, 2023
1 parent e8f84e8 commit 7d8b1b6
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 39 deletions.
11 changes: 11 additions & 0 deletions flint/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 2.8.0 (17/08/2023)
This update focuses on lint rules introduce in Dart 3.1.0.

- Add `matching_super_parameters`
- Add `no_literal_bool_comparisons`
- Add `no_self_assignments`
- Add `no_wildcard_variable_uses`
- Add `unreachable_from_main`
- Remove deprecated `iterable_contains_unrelated_type`
- Remove deprecated `list_remove_unrelated_type`

# 2.7.0 (13/05/2023)
This update focuses on lint rules introduce in Dart 3.

Expand Down
2 changes: 1 addition & 1 deletion flint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Lint rules used by Forus Labs.
To use a ruleset, add `flint` as a dev dependency in your `pubspec.yaml`.
```yaml
dev_dependencies:
flint: ^2.7.0
flint: ^2.8.0
```
Then, add a ruleset to your `analysis_options.yaml`. Flint contains a Dart ruleset & a Flutter ruleset.
Expand Down
13 changes: 8 additions & 5 deletions flint/lib/analysis_options.dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@ linter:
- hash_and_equals
- implementation_imports
- implicit_call_tearoffs
- iterable_contains_unrelated_type
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_annotations
- library_names
- library_prefixes
- library_private_types_in_public_api
- list_remove_unrelated_type
- literal_only_boolean_expressions
- matching_super_parameters
- missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- no_duplicate_case_values
- no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers
- no_literal_bool_comparisons
- no_runtimeType_toString
- no_self_assignments
- no_wildcard_variable_uses
- non_constant_identifier_names
- noop_primitive_operations
- null_check_on_nullable_type_parameter
Expand Down Expand Up @@ -160,6 +162,7 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
- unreachable_from_main
- unrelated_type_equality_checks
- unsafe_html
- use_enums
Expand All @@ -180,15 +183,12 @@ linter:
ignore:
- always_declare_return_types
- always_put_required_named_parameters
- always_require_non_null_named_parameters
- always_specify_types
- avoid_annotating_with_dynamic
- avoid_as
- avoid_classes_with_only_static_members
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_renaming_method_parameters
- avoid_returning_null
- avoid_returning_null_for_future
- avoid_type_to_string
- avoid_web_libraries_in_flutter
- diagnostic_describe_all_properties
Expand All @@ -208,9 +208,12 @@ ignore:
- prefer_relative_imports
- public_member_api_docs
- require_trailing_commas
- sized_box_for_whitespace
- sized_box_shrink_expand
- sort_constructors_first
- sort_unnamed_constructors_first
- unnecessary_final
- use_colored_box
- use_decorated_box
- use_full_hex_values_for_flutter_colors
- use_key_in_widget_constructors
4 changes: 2 additions & 2 deletions flint/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: flint
description: Analyzer lints used internally in Forus Labs' Dart & Flutter projects.
version: 2.7.0
version: 2.8.0
homepage: https://github.com/forus-labs/cauldron
repository: https://github.com/forus-labs/cauldron

environment:
sdk: '>=3.0.0 <4.0.0'
sdk: '>=3.1.0 <4.0.0'

dev_dependencies:
html: ^0.15.0
Expand Down
2 changes: 1 addition & 1 deletion flint/tool/environment.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:io';

import 'package:yaml/yaml.dart';

final Uri remote = Uri.parse('https://raw.githubusercontent.com/dart-lang/linter/master/example/all.yaml');
final Uri remote = Uri.parse('https://dart.dev/tools/linter-rules/all');

final String projectDirectory = (Platform.script.path.split('/')..removeLast()..removeLast()).join('/');

Expand Down
92 changes: 62 additions & 30 deletions flint/tool/update.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,86 @@ import 'dart:io';

import 'package:html/parser.dart' show parse;
import 'package:http/http.dart';
import 'package:yaml/yaml.dart';

import 'environment.dart';

Future<void> main() async => write(await mature(changes(await fetch())).toSet());
Future<void> main() async => write(await process(await fetch()));

Future<Set<String>> fetch() async {
if (!temp.existsSync() || DateTime.now().difference(temp.lastModifiedSync()) > const Duration(days: 1)) {
print('"all_rules.yaml" could not be found/is outdated, downloading from $remote');
print('Fetching lint rules from $remote.');

final response = await get(remote);
temp..createSync(recursive: true)..writeAsStringSync(response.body);
}

return Set.from(loadFile(temp)['linter']['rules'] as YamlList);
final response = parse((await get(remote)).body);
return response.getElementsByClassName('code-excerpt__code').single.innerHtml
.split(RegExp('[ ]+-[ ]+'))
.skip(1)
.map((e) => e.trim())
.toSet();
}

Set<String> changes(Set<String> remote) => remote.difference(<String> {
...rules['linter']['rules'],
...rules['ignore'],
});

Stream<String> mature(Set<String> changes) async* {
for (final change in changes) {
final response = await get(Uri.parse('https://dart-lang.github.io/linter/lints/$change.html'));
Future<(Set<String> released, Set<String> removed)> process(Set<String> remote) async {
final existing = <String> { ...rules['linter']['rules'], ...rules['ignore'] };
final released = <String>{};
final experimental = <String>{};
final removed = <String> {};
for (final rule in remote) {
final response = await get(Uri.parse('https://dart.dev/tools/linter-rules/$rule'));
if (response.statusCode == 404) {
print('Warning: https://dart-lang.github.io/linter/lints/$change.html does not exist (the rule might still be experimental)');
return;
print('Warning: https://dart.dev/tools/linter-rules/$rule does not exist.');
continue;
}

final content = parse(response.body)
.getElementsByClassName('content')[0]
.getElementsByTagName('p')[1]
.getElementsByTagName('em')[0]
.text;

if (existing.contains(rule) && (content.contains('deprecated') || content.contains('removed'))) {
removed.add(rule);
} else if (!existing.contains(rule) && !content.contains('experimental') && !content.contains('deprecated') && !content.contains('removed')) {
released.add(rule);
} if (!existing.contains(rule) && content.contains('experimental')) {
experimental.add(rule);
}
}

final header = parse(response.body).body?.getElementsByClassName('wrapper').first.getElementsByTagName('header').first;
final released = !header!.getElementsByClassName('tooltip').first.getElementsByTagName('p').first.innerHtml.contains('unreleased');
if (released) {
yield change;
if (experimental.isNotEmpty) {
print('The following rules are experimental:');
for (final rule in experimental) {
print('https://dart.dev/tools/linter-rules/$rule');
}
}

return (released, removed);
}

void write(Set<String> changes) {
if (changes.isNotEmpty) {
print('See https://dart-lang.github.io/linter/lints/ for more information on lints');
void write((Set<String> released, Set<String> removed) rules) {
final (Set<String> released, Set<String> removed) = rules;

if (released.isNotEmpty) {
print('The following rules are stable:');
options.writeAsStringSync('\nreleased:\n', mode: FileMode.append);

for (final rule in released) {
print('https://dart.dev/tools/linter-rules/$rule');
options.writeAsStringSync(' - $rule\n', mode: FileMode.append);
}

} else {
print('No new stable lint rules released.');
}

if (removed.isNotEmpty) {
print('The following rules have been removed:');
options.writeAsStringSync('\nremoved:\n', mode: FileMode.append);

options.writeAsStringSync('\nchanges:\n', mode: FileMode.append);
for (final change in changes) {
options.writeAsStringSync(' - $change\n', mode: FileMode.append);
for (final rule in removed) {
print('https://dart.dev/tools/linter-rules/$rule');
options.writeAsStringSync(' - $rule\n', mode: FileMode.append);
}

} else {
print('No changes to lints');
print('No new lint rules removed.');
}
}

0 comments on commit 7d8b1b6

Please sign in to comment.