Skip to content
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

Release/v2.0.0 #20

Merged
merged 38 commits into from
Aug 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
ab90f99
update 2.0.0
blendthink Aug 18, 2022
67f05bc
Remove unnecessary packages
blendthink Aug 19, 2022
ec4198f
refactor lint
blendthink Aug 19, 2022
e944c5f
downgrade dart sdk version to 2.14.0
blendthink Aug 19, 2022
ae787d1
fix strict-casts:true to implicit-casts: false
blendthink Aug 19, 2022
b4fb203
fix cli dir
blendthink Aug 19, 2022
023e5f1
implement parse dart analyze results
blendthink Aug 19, 2022
30647a8
refactor GitRepository
blendthink Aug 19, 2022
eb474e8
add http package
blendthink Aug 19, 2022
a48d52c
remove crypto package
blendthink Aug 19, 2022
6b45b45
fix GetIndicatesUseCase
blendthink Aug 19, 2022
300b9a5
fix elixir.dart
blendthink Aug 19, 2022
e5c956c
implement CommentIndicatesUseCase
blendthink Aug 22, 2022
71282d3
implement close method in GitHubClient
blendthink Aug 23, 2022
fa132dd
fix build.yaml
blendthink Aug 23, 2022
689b576
fix linter
blendthink Aug 23, 2022
6eba891
fix dart sdk version of example
blendthink Aug 23, 2022
6560a5e
refactor version gen
blendthink Aug 23, 2022
c38e034
refactor exception
blendthink Aug 23, 2022
e25bcf6
run dart format
blendthink Aug 23, 2022
03b6130
update CHANGELOG, README
blendthink Aug 23, 2022
dfb75fe
fix data
blendthink Aug 23, 2022
eaf7bf3
change String.fromEnvironment to Platform.environment
blendthink Aug 24, 2022
bb154d9
fix use super.post()
blendthink Aug 24, 2022
f8d6ccb
fix: change Iterable to List
blendthink Aug 25, 2022
5b075a4
refactor message and body
blendthink Aug 25, 2022
28afe9e
build_runner build
blendthink Aug 25, 2022
ee67b4e
change position to line
blendthink Aug 25, 2022
d70be1c
change body to empty
blendthink Aug 25, 2022
1c8091a
refactor message
blendthink Aug 25, 2022
5ed9ba3
update README
blendthink Aug 25, 2022
d920f19
add elixirKey
blendthink Aug 25, 2022
83c5f8a
add getRequest, deleteRequest to GitHubClient
blendthink Aug 25, 2022
3112aef
remove issueCount property
blendthink Aug 25, 2022
e32a7ef
add listReviewComments, deleteReviewComment to GitHubRepository
blendthink Aug 25, 2022
f7224f8
add DeletePreviousCommentsUseCase
blendthink Aug 25, 2022
e6c7b65
implement DeletePreviousCommentsUseCase
blendthink Aug 25, 2022
6ef94e1
fix delete previous comments
blendthink Aug 25, 2022
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: update-pubspec
name: update-version

on:
workflow_dispatch:
Expand Down Expand Up @@ -38,9 +38,9 @@ jobs:
uses: peter-evans/create-pull-request@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: auto format
title: Auto Format
commit-message: update version
title: Update version
body: This was automatically generated by the [${{ github.workflow }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
base: main
branch: update-pubspec
branch: update-version
branch-suffix: short-commit-hash
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## 2.0.0

### Changed

- Changed to use "Create a review for a pull request" API.
- https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request
- Changed to use `dart analyze --format=machine` command.

### Improved

- Supported for Dart SDK 2.15.0.
- Reduced dependent packages.

## 1.0.6

### Fixed
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

# Elixir

A command-line tool for commenting `dart analyze` results to GitHub PullRequest.
A command-line tool for commenting `dart analyze --format=machine $dir` results to GitHub PullRequest.

## Required

- Dart SDK version >=2.15.0 <3.0.0

## Usage

Expand All @@ -26,7 +30,7 @@ jobs:
- uses: dart-lang/setup-dart@v1

# https://github.com/blendthink/elixir
- uses: blendthink/elixir@v1
- uses: blendthink/elixir@v2
with:
# (Optional) GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT).
# Default: ${{ github.token }}
Expand All @@ -39,25 +43,21 @@ jobs:

### CLI

This package uses Git and GitHub CLI internally.
This package uses Git internally.

If you are using GitHub Actions, you can skip steps 1 and 2.
If you are using GitHub Actions, you can skip steps 1.

#### 1. Install Git

https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

#### 2. Install GitHub CLI

https://github.com/cli/cli#installation

#### 3. Active package
#### 2. Active package

```shell
dart pub global activate elixir
```

#### 4. Run package
#### 3. Run package

```shell
cd {git-repository-path}
Expand Down
194 changes: 190 additions & 4 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,191 @@
include: package:lints/recommended.yaml

analyzer:
errors:
invalid_annotation_target: ignore
exclude:
- example/**
strong-mode:
implicit-casts: false
language:
strict-inference: true
strict-raw-types: true

linter:
rules:
# Error Rules
- always_use_package_imports
- avoid_dynamic_calls
- avoid_empty_else
- avoid_relative_lib_imports
- avoid_slow_async_io
- avoid_type_to_string
- avoid_types_as_parameter_names
- avoid_web_libraries_in_flutter
- cancel_subscriptions
- close_sinks
- comment_references
- control_flow_in_finally
- empty_statements
- hash_and_equals
- iterable_contains_unrelated_type
- list_remove_unrelated_type
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_duplicate_case_values
- no_logic_in_create_state
- prefer_void_to_null
- test_types_in_equals
- throw_in_finally
- unnecessary_statements
- unrelated_type_equality_checks
- unsafe_html
- use_build_context_synchronously
- use_key_in_widget_constructors
- valid_regexps

# Style Rules
- always_declare_return_types
- always_require_non_null_named_parameters
- annotate_overrides
- avoid_annotating_with_dynamic
- avoid_bool_literals_in_conditional_expressions
- avoid_catches_without_on_clauses
- avoid_catching_errors
- avoid_classes_with_only_static_members
- avoid_double_and_int_checks
- avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
- avoid_init_to_null
- avoid_js_rounded_ints
- avoid_multiple_declarations_per_line
- avoid_null_checks_in_equality_operators
- avoid_equals_and_hash_code_on_mutable_classes
- avoid_positional_boolean_parameters
- avoid_private_typedef_functions
- avoid_redundant_argument_values
- avoid_renaming_method_parameters
- avoid_returning_null_for_void
- avoid_returning_this
- avoid_return_types_on_setters
- avoid_setters_without_getters
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_types_on_closure_parameters
- avoid_unnecessary_containers
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_extensions
- camel_case_types
- cascade_invocations
- cast_nullable_to_non_nullable
- constant_identifier_names
- curly_braces_in_flow_control_structures
- deprecated_consistency
- directives_ordering
- empty_catches
- empty_constructor_bodies
- eol_at_end_of_file
- exhaustive_cases
- file_names
- flutter_style_todos
- implementation_imports
- join_return_with_assignment
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
- library_private_types_in_public_api
- lines_longer_than_80_chars
- missing_whitespace_between_adjacent_strings
- no_default_cases
- non_constant_identifier_names
- noop_primitive_operations
- no_runtimeType_toString
- null_check_on_nullable_type_parameter
- null_closures
- omit_local_variable_types
- only_throw_errors
- overridden_fields
- package_api_docs
- package_prefixed_library_names
- parameter_assignments
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
- 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_equal_for_default_values
- prefer_expression_function_bodies
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
- prefer_foreach
- 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_interpolation_to_compose_strings
- prefer_int_literals
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
- prefer_mixin
- prefer_null_aware_operators
- prefer_null_aware_method_calls
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- provide_deprecation_message
#- public_member_api_docs
- recursive_getters
- require_trailing_commas
- sized_box_for_whitespace
- slash_for_doc_comments
- sort_child_properties_last
- sort_constructors_first
- sort_unnamed_constructors_first
- tighten_type_of_initializing_formals
- type_annotate_public_apis
- type_init_formals
- unawaited_futures
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_const
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_getters_setters
- unnecessary_lambdas
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_null_checks
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_raw_strings
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
- use_is_even_rather_than_modulo
- use_late_for_private_fields_and_variables
- use_named_constants
- use_rethrow_when_possible
- use_raw_strings
- use_setters_to_change_properties
- use_string_buffers
- use_test_throws_matchers
- use_to_and_as_if_applicable
- void_checks

# Pub Rules
- depend_on_referenced_packages
- package_names
- sort_pub_dependencies
2 changes: 1 addition & 1 deletion bin/elixir.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import 'package:elixir/elixir.dart' as elixir;

Future<void> main(List<String> args) async => await elixir.run(args);
Future<void> main(List<String> args) async => elixir.run(args);
7 changes: 3 additions & 4 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ targets:
options:
ignore_for_file:
- non_constant_identifier_names
json_serializable|freezed:
mockito|mockBuilder:
generate_for:
include:
- "lib/data/model/*.dart"
- "test/**.dart"
exclude:
- "lib/data/model/*.freezed.dart"
- "lib/data/model/*.g.dart"
- "test/**.mocks.dart"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ description: A example of Elixir.
version: 1.0.0
publish_to: 'none'
environment:
sdk: '>=2.17.5 <3.0.0'
sdk: '>=2.15.0 <3.0.0'
50 changes: 20 additions & 30 deletions lib/cli/command/run.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:convert';

import 'package:args/args.dart' show ArgResults;
import 'package:args/command_runner.dart';
Expand All @@ -10,30 +9,17 @@ import 'package:elixir/cli/option/head.dart';
import 'package:elixir/cli/option/num.dart';
import 'package:elixir/cli/option/repo.dart';
import 'package:elixir/usecase/comment_indicates.dart';
import 'package:elixir/usecase/filter_indicates.dart';
import 'package:elixir/usecase/delete_previous_comments.dart';
import 'package:elixir/usecase/get_indicates.dart';
import 'package:elixir/util/log.dart';

class RunCommand extends Command<dynamic> {
@override
String get name => 'run';

@override
String get description =>
'Run `dart analyze` and comment on the GitHub Pull Request.';

final _encoder = JsonEncoder.withIndent(' ');

final GetIndicatesUseCase _getIndicates;
final FilterIndicatesUseCase _filterIndicates;
final CommentIndicatesUseCase _commentIndicates;

RunCommand({
GetIndicatesUseCase getIndicates = const GetIndicatesUseCase(),
FilterIndicatesUseCase filterIndicates = const FilterIndicatesUseCase(),
CommentIndicatesUseCase commentIndicates = const CommentIndicatesUseCase(),
required DeletePreviousCommentsUseCase deletePreviousComments,
required CommentIndicatesUseCase commentIndicates,
}) : _getIndicates = getIndicates,
_filterIndicates = filterIndicates,
_deletePreviousComments = deletePreviousComments,
_commentIndicates = commentIndicates {
argParser.addOptions([
RepoOption(),
Expand All @@ -44,6 +30,17 @@ class RunCommand extends Command<dynamic> {
]);
}

@override
String get name => 'run';

@override
String get description =>
'Run `dart analyze` and comment on the GitHub Pull Request.';

final GetIndicatesUseCase _getIndicates;
final DeletePreviousCommentsUseCase _deletePreviousComments;
final CommentIndicatesUseCase _commentIndicates;

@override
FutureOr<dynamic>? run() async {
final repo = RepoOption.repo(argResults, usageException);
Expand All @@ -58,25 +55,18 @@ class RunCommand extends Command<dynamic> {
head: head,
);
if (indicates.isEmpty) {
return;
}

final filteredIndicates = await _filterIndicates(
repo: repo,
num: num,
indicates: indicates,
);
if (filteredIndicates.isEmpty) {
log.i('In this Pull Request ( #$num ), no issues found!');
return;
}

final reviewComments = await _commentIndicates(
await _deletePreviousComments(repo: repo, num: num);

final result = await _commentIndicates(
repo: repo,
num: num,
indicates: filteredIndicates,
indicates: indicates,
);
log.i(_encoder.convert(reviewComments));
log.i(result);
}

@override
Expand Down
Loading