Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
crispy-riccardo committed Oct 3, 2023
0 parents commit dc68417
Show file tree
Hide file tree
Showing 19 changed files with 577 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Every request must be reviewed and accepted by:

* @crispy-riccardo
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
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.
16 changes: 16 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
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.
23 changes: 23 additions & 0 deletions .github/pull_request_template.md
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dart_tool
.packages
pubspec.lock
.DS_Store
.idea
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 1.0.0

- First release
39 changes: 39 additions & 0 deletions CONTRIBUTING.md
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.
89 changes: 89 additions & 0 deletions README.md
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
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: lib/analysis_options.yaml
Binary file added assets/crispybacon_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions example/analysis_options.yaml
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
35 changes: 35 additions & 0 deletions example/lib/class_example.dart
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
}
}
96 changes: 96 additions & 0 deletions example/lib/example.dart
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');
}
}
6 changes: 6 additions & 0 deletions example/lib/extensions.dart
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)}";
}
}
10 changes: 10 additions & 0 deletions example/pubspec.yaml
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: ../
Loading

0 comments on commit dc68417

Please sign in to comment.