-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc68417
Showing
19 changed files
with
577 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Every request must be reviewed and accepted by: | ||
|
||
* @crispy-riccardo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
Thanks for contributing! | ||
Provide a description of your changes below and a general summary in the title | ||
Please look at the following checklist to ensure that your PR can be accepted quickly: | ||
--> | ||
|
||
## Description | ||
|
||
<!--- Describe your changes in detail --> | ||
|
||
## Type of Change | ||
|
||
<!--- Put an `x` in all the boxes that apply: --> | ||
|
||
- [ ] ✨ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.dart_tool | ||
.packages | ||
pubspec.lock | ||
.DS_Store | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 1.0.0 | ||
|
||
- First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: lib/analysis_options.yaml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include: package:crispy_analysis/analysis_options.yaml | ||
|
||
linter: | ||
rules: | ||
public_member_api_docs: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extension StringExtension on String { | ||
/// prefer_single_quotes | ||
String get capitalize { | ||
return "${this[0].toUpperCase()}${this.substring(1)}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: ../ |
Oops, something went wrong.