From dc6841736400e23a9c72950c4ddd93c66f4b3e27 Mon Sep 17 00:00:00 2001 From: Riccardo Strazzer Date: Tue, 3 Oct 2023 14:12:41 +0200 Subject: [PATCH] first commit --- .github/CODEOWNERS | 3 + .github/ISSUE_TEMPLATE/bug_report.md | 24 +++ .github/ISSUE_TEMPLATE/feature_request.md | 16 ++ .github/pull_request_template.md | 23 +++ .gitignore | 5 + CHANGELOG.md | 3 + CONTRIBUTING.md | 39 ++++ README.md | 89 ++++++++++ analysis_options.yaml | 1 + assets/crispybacon_logo.png | Bin 0 -> 4521 bytes example/analysis_options.yaml | 5 + example/lib/class_example.dart | 35 ++++ example/lib/example.dart | 96 ++++++++++ example/lib/extensions.dart | 6 + example/pubspec.yaml | 10 ++ lib/analysis_options.1.0.0.yaml | 207 ++++++++++++++++++++++ lib/analysis_options.yaml | 1 + lib/crispy_analysis.dart | 3 + pubspec.yaml | 11 ++ 19 files changed, 577 insertions(+) create mode 100644 .github/CODEOWNERS create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/pull_request_template.md create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 README.md create mode 100644 analysis_options.yaml create mode 100644 assets/crispybacon_logo.png create mode 100644 example/analysis_options.yaml create mode 100644 example/lib/class_example.dart create mode 100644 example/lib/example.dart create mode 100644 example/lib/extensions.dart create mode 100644 example/pubspec.yaml create mode 100644 lib/analysis_options.1.0.0.yaml create mode 100644 lib/analysis_options.yaml create mode 100644 lib/crispy_analysis.dart create mode 100644 pubspec.yaml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..e3b0cf7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# Every request must be reviewed and accepted by: + +* @crispy-riccardo diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..cddd619 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,24 @@ +--- +name: Bug report +about: Create a report to help us improve +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..a09db44 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,16 @@ +--- +name: Feature request +about: Suggest an idea for this project +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..6b9372e --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,23 @@ + + +## Description + + + +## Type of Change + + + +- [ ] โœจ New feature (non-breaking change which adds functionality) +- [ ] ๐Ÿ› ๏ธ Bug fix (non-breaking change which fixes an issue) +- [ ] โŒ Breaking change (fix or feature that would cause existing functionality to change) +- [ ] ๐Ÿงน Code refactor +- [ ] โœ… Build configuration change +- [ ] ๐Ÿ“ Documentation +- [ ] ๐Ÿ—‘๏ธ Chore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9001448 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.dart_tool +.packages +pubspec.lock +.DS_Store +.idea diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..99b639e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# 1.0.0 + +- First release diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c79c81d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing to Crispy Analysis + +๐Ÿ‘๐ŸŽ‰ First off, thanks for taking the time to contribute! ๐ŸŽ‰๐Ÿ‘ + +These are mostly guidelines, not rules. Use your best judgment, +and feel free to propose changes to this document in a pull request. + +## Proposing a Change + +If you intend to change the public API, or make any non-trivial changes +to the implementation, we recommend filing an issue. +This lets us reach an agreement on your proposal before you put significant +effort into it. + +If youโ€™re only fixing a bug, itโ€™s fine to submit a pull request right away +but we still recommend to file an issue detailing what youโ€™re fixing. +This is helpful in case we donโ€™t accept that specific fix but want to keep +track of the issue. + +## Creating a Pull Request + +Before creating a pull request please: + +1. Fork the repository and create your branch from `main`. +1. Install all dependencies (`flutter packages get` or `pub get`). +1. Squash your commits and ensure you have a meaningful commit message. +1. If youโ€™ve fixed a bug or added code that should be tested, add tests! + Pull Requests without 100% test coverage will not be approved. +1. Ensure the test suite passes. +1. If you've changed the public API, make sure to update/add documentation. +1. Format your code (`dartfmt -w .`). +1. Analyze your code (`dartanalyzer --fatal-infos --fatal-warnings .`). +1. Create the Pull Request. +1. Verify that all status checks are passing. + +While the prerequisites above must be satisfied prior to having your +pull request reviewed, the reviewer(s) may ask you to complete additional +design work, tests, or other changes before your pull request can be ultimately +accepted. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5c0327a --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# Crispy Analysis + +[![Crispy Bacon SRL][logo]][crispy_link] + +Maintained by [Riccardo Strazzer][maintainer_link] + +[![style: crispy analysis][badge]][badge_link] + +--- + +This package provides lint rules for Dart and Flutter which are used at [Crispy Bacon SRL][crispy_bacon_link]. For more information, see the [complete list of options][analysis_options_yaml]. + +The example folder contains some example. If you find some cases where some rules are too aggressive please fill a issue and we can discuss about it's removal. + +## Usage + +To use the lints, add as a dev dependency in your `pubspec.yaml`: + +```yaml +crispy_analysis: + git: https://github.com/crispybaconsrl/crispy_analysis +``` + +Then, add an include in `analysis_options.yaml`: + +```yaml +include: package:crispy_analysis/analysis_options.yaml +``` + +This will ensure you always use the latest version of the lints. If you wish to restrict the lint version, specify a version of `analysis_options.yaml` instead: + +```yaml +include: package:crispy_analysis/analysis_options.1.0.0.yaml +``` + +## Suppressing Lints + +There may be cases where specific lint rules are undesirable. Lint rules can be suppressed at the line, file, or project level. + +An example use case for suppressing lint rules at the file level is suppressing the `prefer_const_constructors` in order to achieve 100% code coverage. This is due to the fact that const constructors are executed before the tests are run, resulting in no coverage collection. + +### Line Level + +To suppress a specific lint rule for a specific line of code, use an `ignore` comment directly above the line: + +```dart +// ignore: public_member_api_docs +class A {} +``` + +### File Level + +To suppress a specific lint rule of a specific file, use an `ignore_for_file` comment at the top of the file: + +```dart +// ignore_for_file: public_member_api_docs + +class A {} + +class B {} +``` + +### Project Level + +To suppress a specific lint rule for an entire project, modify `analysis_options.yaml`: + +```yaml +include: package:crispy_analysis/analysis_options.yaml +linter: + rules: + public_member_api_docs: false +``` + +## Badge + +To indicate your project is using `crispy_analysis` โ†’ +[![style: crispy analysis][badge]][badge_link] + +```md +[![style: crispy analysis](https://img.shields.io/badge/style-crispy_analysis-A1022B.svg)](https://github.com/crispybaconsrl/crispy_analysis) +``` + +[analysis_options_yaml]: https://github.com/crispybaconsrl/crispy_analysis/blob/main/lib/analysis_options.1.0.0.yaml +[badge]: https://img.shields.io/badge/style-crispy_analysis-A1022B.svg +[badge_link]: https://github.com/crispybaconsrl/crispy_analysis +[logo]: ./assets/crispybacon_logo.png +[crispy_bacon_link]: https://crispybacon.it +[crispy_link]: https://crispybacon.it +[maintainer_link]: https://github.com/crispy-riccardo diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 0000000..a4bfc29 --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1 @@ +include: lib/analysis_options.yaml diff --git a/assets/crispybacon_logo.png b/assets/crispybacon_logo.png new file mode 100644 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-ro? zt~_(;5fv~k-g7u8$dBdBZ8B!oX#l1mnu(Y)>ArF{u&ylDK0XmBMJzq#A&{B6^V*Oe zpJg30m5z}~ZF4mUe;m0rvGsi$bJFR^Kmz6Cli1He&WOR6R`~wH7iVkN)kCuUhY{+&LHb)-Gt}EWQD$YZ^6UU)-^MiNt0MyUVDN!s}ysC)N@)3k4{P5Y%X3@WJgdW)9;i0Wvdc zyk?}|7X+1kBUdB_nu z1P=K9`yYz)AUPXsYvF5 z%V48DSq&;){l|L{Z8Q~roz30e&2^~pJx}o>-_d}NLrwlvPR4NUk%L!pFBn{02r-lt tp@*$XIwTF*N4scCoA{WmIA`7v`No|uk#5m!{CiChX+iYVtHE~B{{`0xpw9pR literal 0 HcmV?d00001 diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml new file mode 100644 index 0000000..021d9ac --- /dev/null +++ b/example/analysis_options.yaml @@ -0,0 +1,5 @@ +include: package:crispy_analysis/analysis_options.yaml + +linter: + rules: + public_member_api_docs: false \ No newline at end of file diff --git a/example/lib/class_example.dart b/example/lib/class_example.dart new file mode 100644 index 0000000..553e039 --- /dev/null +++ b/example/lib/class_example.dart @@ -0,0 +1,35 @@ +abstract class Dog { + String get breed; + + String get color; + + /// avoid_return_types_on_setters + void set color(String color); + + /// avoid_setters_without_getters + set owner(String owner); + + void feed(String food); +} + +class Husky extends Dog { + @override + final String breed = 'Husky'; + + /// annotate_overrides + final String color = 'Black'; + + @override + set color(String color) { + /// avoid_returning_null_for_void + return null; + } + + @override + set owner(String owner) {} + + @override + void feed(String whatFood) { + /// avoid_renaming_method_parameters + } +} diff --git a/example/lib/example.dart b/example/lib/example.dart new file mode 100644 index 0000000..1411032 --- /dev/null +++ b/example/lib/example.dart @@ -0,0 +1,96 @@ +// The following syntax deactivates a lint for the entire file: +// ignore_for_file: avoid_print + +import 'dart:math'; + +import './extensions.dart'; + +void main() { + /// The following line would normally show a lint warning + /// but we can disable the lint rule for this line using the following syntax. + var greeting = 'hello world'; // ignore: prefer_final_locals + + /// The following line would normally show a lint warning + /// but we can disable the lint rule for this file using `ignore_for_file`. + print(greeting); + + final classExample = ClassExample(); + + /// avoid_single_cascade_in_expression_statements + classExample..methodExample(test2: ''); + + /// avoid_init_to_null + /// prefer_const_declarations + final String? initToNull = null; + print(initToNull); + + /// always_declare_return_types + var _example = simpleMethod(); + String example2 = simpleMethodForcedType(); + + classExample.methodExample(test2: 'test'); + + print(_example.capitalize); + print(example2.capitalize); + + /// avoid_bool_literals_in_conditional_expressions + final bool test = Random().nextBool() ? true : false; + + if (test) { + print('true'); + } else { + print('false'); + } + + /// avoid_escaping_inner_quotes + print('It\'s not fun'); + print("It's not fun"); + + /// avoid_function_literals_in_foreach_calls + /// unnecessary_lambdas + [1, 2, 3, 4, 5, 6].forEach((element) => print(element)); + + /// avoid_multiple_declarations_per_line + String? a, b, c; + print([a, b, c]); + + /// avoid_redundant_argument_values + changeActive2(isActive: true); + changeActive2(isActive: false); +} + +/// always_declare_return_types +simpleMethod() { + return 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; +} + +String simpleMethodForcedType() { + return 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; +} + +/// avoid_positional_boolean_parameters +void changeActive(bool isActive) { + // do something +} + +void changeActive2({bool isActive = false}) { + // do something +} + +/// avoid_private_typedef_functions +typedef void _PrivateTypeDef(); + +class ClassExample { + final String firstVariable; + final String secondVariable; + + ClassExample({ + this.firstVariable = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', + this.secondVariable = '', + }); + + /// always_put_required_named_parameters_first + void methodExample({String? test, required String test2}) { + print('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. $test $test2'); + } +} diff --git a/example/lib/extensions.dart b/example/lib/extensions.dart new file mode 100644 index 0000000..fac403c --- /dev/null +++ b/example/lib/extensions.dart @@ -0,0 +1,6 @@ +extension StringExtension on String { + /// prefer_single_quotes + String get capitalize { + return "${this[0].toUpperCase()}${this.substring(1)}"; + } +} diff --git a/example/pubspec.yaml b/example/pubspec.yaml new file mode 100644 index 0000000..36a3965 --- /dev/null +++ b/example/pubspec.yaml @@ -0,0 +1,10 @@ +name: crispy_analysis_example +version: 0.0.1 +publish_to: none + +environment: + sdk: ">=2.18.0 <3.0.0" + +dependencies: + crispy_analysis: + path: ../ diff --git a/lib/analysis_options.1.0.0.yaml b/lib/analysis_options.1.0.0.yaml new file mode 100644 index 0000000..330d006 --- /dev/null +++ b/lib/analysis_options.1.0.0.yaml @@ -0,0 +1,207 @@ +analyzer: + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + + errors: + close_sinks: ignore + missing_required_param: error + missing_return: error + record_literal_one_positional_no_trailing_comma: error + collection_methods_unrelated_type: warning + unrelated_type_equality_checks: warning + + exclude: + - test/.test_coverage.dart + - lib/generated_plugin_registrant.dart + - '**/*.locator.dart' + - '**/*.logger.dart' + - '**/*.router.dart' + +linter: + rules: + - always_declare_return_types + - always_put_required_named_parameters_first + - always_use_package_imports + - annotate_overrides + - avoid_bool_literals_in_conditional_expressions + - avoid_catching_errors + - avoid_double_and_int_checks + - avoid_dynamic_calls + - avoid_empty_else + - avoid_equals_and_hash_code_on_mutable_classes + - avoid_escaping_inner_quotes + - avoid_field_initializers_in_const_classes + - avoid_final_parameters + - avoid_function_literals_in_foreach_calls + - avoid_init_to_null + - avoid_js_rounded_ints + - avoid_multiple_declarations_per_line + - avoid_null_checks_in_equality_operators + - avoid_positional_boolean_parameters + - avoid_print + - avoid_private_typedef_functions + - avoid_redundant_argument_values + - avoid_relative_lib_imports + - avoid_renaming_method_parameters + - avoid_return_types_on_setters + - avoid_returning_null_for_void + - avoid_returning_this + - avoid_setters_without_getters + - avoid_shadowing_type_parameters + - avoid_single_cascade_in_expression_statements + - avoid_slow_async_io + - avoid_type_to_string + - avoid_types_as_parameter_names + - avoid_unnecessary_containers + - avoid_unused_constructor_parameters + - avoid_void_async + - avoid_web_libraries_in_flutter + - await_only_futures + - camel_case_extensions + - camel_case_types + - cancel_subscriptions + - cascade_invocations + - cast_nullable_to_non_nullable + - collection_methods_unrelated_type + - combinators_ordering + - comment_references + - conditional_uri_does_not_exist + - constant_identifier_names + - control_flow_in_finally + - curly_braces_in_flow_control_structures + - dangling_library_doc_comments + - depend_on_referenced_packages + - deprecated_consistency + - directives_ordering + - empty_catches + - empty_constructor_bodies + - empty_statements + - eol_at_end_of_file + - exhaustive_cases + - file_names + - flutter_style_todos + - hash_and_equals + - implicit_call_tearoffs + - implementation_imports + - implicit_reopen + - invalid_case_patterns + - join_return_with_assignment + - leading_newlines_in_multiline_strings + - library_annotations + - library_names + - library_prefixes + - library_private_types_in_public_api + - literal_only_boolean_expressions + - missing_whitespace_between_adjacent_strings + - no_adjacent_strings_in_list + - no_default_cases + - no_duplicate_case_values + - no_leading_underscores_for_library_prefixes + - no_leading_underscores_for_local_identifiers + - no_logic_in_create_state + - no_runtimeType_toString + - non_constant_identifier_names + - noop_primitive_operations + - null_check_on_nullable_type_parameter + - null_closures + - one_member_abstracts + - only_throw_errors + - overridden_fields + - package_api_docs + - package_names + - package_prefixed_library_names + - parameter_assignments + - prefer_adjacent_string_concatenation + - prefer_asserts_in_initializer_lists + - prefer_asserts_with_message + - prefer_collection_literals + - prefer_conditional_assignment + - prefer_const_constructors + - prefer_const_constructors_in_immutables + - prefer_const_declarations + - prefer_const_literals_to_create_immutables + - prefer_constructors_over_static_methods + - prefer_contains + - prefer_final_fields + - prefer_final_in_for_each + - prefer_final_locals + - prefer_for_elements_to_map_fromIterable + - prefer_function_declarations_over_variables + - prefer_generic_function_type_aliases + - prefer_if_elements_to_conditional_expressions + - prefer_if_null_operators + - prefer_initializing_formals + - prefer_inlined_adds + - prefer_int_literals + - prefer_interpolation_to_compose_strings + - prefer_is_empty + - prefer_is_not_empty + - prefer_is_not_operator + - prefer_iterable_whereType + - prefer_null_aware_method_calls + - prefer_null_aware_operators + - prefer_single_quotes + - prefer_spread_collections + - prefer_typing_uninitialized_variables + - prefer_void_to_null + - provide_deprecation_message + - public_member_api_docs + - recursive_getters + - require_trailing_commas + - secure_pubspec_urls + - sized_box_for_whitespace + - sized_box_shrink_expand + - slash_for_doc_comments + - sort_child_properties_last + - sort_constructors_first + - sort_unnamed_constructors_first + - test_types_in_equals + - throw_in_finally + - tighten_type_of_initializing_formals + - type_annotate_public_apis + - type_init_formals + - unawaited_futures + - unnecessary_await_in_return + - unnecessary_breaks + - unnecessary_brace_in_string_interps + - unnecessary_const + - unnecessary_constructor_name + - unnecessary_getters_setters + - unnecessary_lambdas + - unnecessary_late + - unnecessary_library_directive + - unnecessary_new + - unnecessary_null_aware_assignments + - unnecessary_null_checks + - unnecessary_null_in_if_null_operators + - unnecessary_nullable_for_final_variable_declarations + - unnecessary_overrides + - unnecessary_parenthesis + - unnecessary_raw_strings + - unnecessary_statements + - unnecessary_string_escapes + - unnecessary_string_interpolations + - unnecessary_this + - unnecessary_to_list_in_spreads + - unrelated_type_equality_checks + - use_colored_box + - use_enums + - use_full_hex_values_for_flutter_colors + - use_function_type_syntax_for_parameters + - use_if_null_to_convert_nulls_to_bools + - use_is_even_rather_than_modulo + - use_key_in_widget_constructors + - use_late_for_private_fields_and_variables + - use_named_constants + - use_raw_strings + - use_rethrow_when_possible + - use_setters_to_change_properties + - use_string_buffers + - use_string_in_part_of_directives + - use_super_parameters + - use_test_throws_matchers + - use_to_and_as_if_applicable + - valid_regexps + - void_checks diff --git a/lib/analysis_options.yaml b/lib/analysis_options.yaml new file mode 100644 index 0000000..f090fcc --- /dev/null +++ b/lib/analysis_options.yaml @@ -0,0 +1 @@ +include: package:crispy_analysis/analysis_options.1.0.0.yaml diff --git a/lib/crispy_analysis.dart b/lib/crispy_analysis.dart new file mode 100644 index 0000000..8e465b8 --- /dev/null +++ b/lib/crispy_analysis.dart @@ -0,0 +1,3 @@ +/// CrispyBacon Dart analyzer settings and best practices +/// used internally at [CrispyBacon](https://crispybacon.it). +library crispy_analysis; diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 0000000..83c9e89 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,11 @@ +name: crispy_analysis +version: 1.0.0 +description: Lint rules for Dart and Flutter used at CrispyBacon SRL. +repository: https://github.com/crispybaconsrl/crispy_analysis +issue_tracker: https://github.com/crispybaconsrl/crispy_analysis/issues +homepage: https://github.com/crispybaconsrl/crispy_analysis +documentation: https://github.com/crispybaconsrl/crispy_analysis +topics: [lints, analyzer, analysis] + +environment: + sdk: ">=3.0.0 <4.0.0"