Skip to content

Commit 381e631

Browse files
authored
Merge pull request #3 from bitsydarel/update_release_pipeline
Updated script to version 2.0.4 and added json reporter
2 parents 78dd2fd + ca6d445 commit 381e631

26 files changed

+1067
-337
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ name: Dart
22

33
on:
44
push:
5-
branches:
6-
# Push events to branches matching refs/heads/releases/[version]
7-
- 'release/**'
5+
tags:
6+
- 'v*'
87

98
jobs:
109
build:
@@ -48,20 +47,22 @@ jobs:
4847
steps:
4948
- uses: actions/checkout@v2
5049

50+
- name: Get the tag name
51+
id: get_tag_name
52+
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
53+
5154
- name: Create a Release
5255
id: create_release
5356
uses: actions/create-release@v1.1.4
5457
env:
5558
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5659
with:
57-
# The name of the tag. This should come from the webhook payload, `github.GITHUB_REF` when a user pushes a new tag
58-
tag_name: ${{ github.ref }}
60+
tag_name: ${{ steps.get_tag_name.outputs.TAG_NAME }}
5961
# The name of the release. For example, `Release v1.0.1`
60-
release_name: Release ${{ github.ref }}
62+
release_name: Release ${{ steps.get_tag_name.outputs.TAG_NAME }}
6163
# Path to file with information about the tag.
6264
body_path: CHANGELOG.md # optional
6365

64-
6566
release-linux:
6667
needs: [ release ]
6768

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,10 @@
3333

3434
## 2.0.3
3535

36-
- code cleanup and improvement
36+
- code cleanup and improvement
37+
38+
## 2.0.4
39+
40+
- Added new reporter for json
41+
42+
- Cleanup code and documentation

bin/dbstyleguidechecker.dart

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
/*
2+
* BSD 3-Clause License
3+
*
4+
* Copyright (c) 2020, Bitsy Darel
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
*
13+
* 2. Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* 3. Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived from
19+
* this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR
28+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
134
import 'dart:async';
235
import 'dart:io';
336

@@ -37,7 +70,7 @@ Future<void> main(List<String> arguments) async {
3770
CodeStyleViolationsChecker checker;
3871

3972
try {
40-
final CodeStylesViolationsReporter reporter =
73+
final CodeStyleViolationsReporter reporter =
4174
_createReporter(scriptArgument);
4275

4376
checker = _createChecker(scriptArgument, reporter);
@@ -59,7 +92,7 @@ Future<void> main(List<String> arguments) async {
5992

6093
CodeStyleViolationsChecker _createChecker(
6194
final ScriptArgument scriptArgument,
62-
final CodeStylesViolationsReporter reporter,
95+
final CodeStyleViolationsReporter reporter,
6396
) {
6497
switch (scriptArgument.projectType) {
6598
case dartProjectType:
@@ -81,31 +114,29 @@ CodeStyleViolationsChecker _createChecker(
81114
default:
82115
throw UnrecoverableException(
83116
'Invalid project type specified, '
84-
"supported are ${supportedProjectType.join(", ")}",
117+
"supported are ${supportedProjectType.join(", ")}",
85118
exitInvalidArgument,
86119
);
87120
}
88121
}
89122

90-
CodeStylesViolationsReporter _createReporter(
123+
CodeStyleViolationsReporter _createReporter(
91124
final ScriptArgument scriptArgument,
92125
) {
93126
switch (scriptArgument.reporterType) {
94127
case reporterOfTypeConsole:
95128
return const ConsoleCodeStyleViolationsReporter();
96-
break;
97129
case reporterOfTypeFile:
98130
final File reporterOutputFile = scriptArgument.reporterOutputFile;
99131

100132
if (reporterOutputFile == null) {
101133
throw const UnrecoverableException(
102134
"Reporter of type 'file' specified "
103-
'but reporter output file not specified.',
135+
'but reporter output file not specified.',
104136
exitMissingRequiredArgument,
105137
);
106138
}
107139
return FileCodeStyleViolationsReporter(reporterOutputFile);
108-
break;
109140
case reporterOfTypeGithub:
110141
final VcsArgument vcs = scriptArgument.vcs;
111142

@@ -122,7 +153,8 @@ CodeStylesViolationsReporter _createReporter(
122153
vcs.pullRequestId,
123154
vcs.accessToken,
124155
);
125-
break;
156+
case reporterOfTypeJson:
157+
return const JsonCodeStyleViolationReporter();
126158
default:
127159
throw const UnrecoverableException(
128160
'Invalid reporter type provided or not supported',

example/lib/example.dart

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
/*
2+
* BSD 3-Clause License
3+
*
4+
* Copyright (c) 2020, Bitsy Darel
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
*
13+
* 2. Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* 3. Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived from
19+
* this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR
28+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
134
void main() {
235
List.generate(10, (index) => SomeConstClass(7))
336
.map((some) => print(some.immutableNumber));

lib/dbstyleguidechecker.dart

Lines changed: 54 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,57 @@
1+
/*
2+
* BSD 3-Clause License
3+
*
4+
* Copyright (c) 2020, Bitsy Darel
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
*
13+
* 2. Redistributions in binary form must reproduce the above copyright notice,
14+
* this list of conditions and the following disclaimer in the documentation
15+
* and/or other materials provided with the distribution.
16+
*
17+
* 3. Neither the name of the copyright holder nor the names of its
18+
* contributors may be used to endorse or promote products derived from
19+
* this software without specific prior written permission.
20+
*
21+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27+
* SUBSTITUTE GOODS OR
28+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
*/
33+
134
library dbstyleguidechecker;
235

336
import 'dart:io';
437
import 'package:meta/meta.dart' show protected;
538

6-
import 'package:dbstyleguidechecker/src/style_guide_violation.dart';
39+
import 'package:dbstyleguidechecker/src/code_style_violation.dart';
740

8-
export 'package:dbstyleguidechecker/src/checkers/dart/dart_project_style_guide_checker.dart';
9-
export 'package:dbstyleguidechecker/src/checkers/dart/flutter_project_style_guide_checker.dart';
41+
export 'package:dbstyleguidechecker/src/checkers/dart_project_style_guide_checker.dart';
42+
export 'package:dbstyleguidechecker/src/checkers/flutter_project_style_guide_checker.dart';
1043
export 'package:dbstyleguidechecker/src/reporters/console_code_style_violations_reporter.dart';
1144
export 'package:dbstyleguidechecker/src/reporters/github/github_pull_request_style_guide_check_reporter.dart';
12-
export 'package:dbstyleguidechecker/src/reporters/file_style_guide_violation_reporter.dart';
13-
export 'package:dbstyleguidechecker/src/parsers/dart/dart_analyzer_violation_parser.dart';
45+
export 'package:dbstyleguidechecker/src/reporters/file_code_style_violation_reporter.dart';
46+
export 'package:dbstyleguidechecker/src/parsers/dart_analyzer_violation_parser.dart';
1447
export 'package:dbstyleguidechecker/src/exceptions.dart';
1548
export 'package:dbstyleguidechecker/src/utils/script_utils.dart';
1649
export 'package:dbstyleguidechecker/src/reporters/github/github_utils.dart';
50+
export 'package:dbstyleguidechecker/src/reporters/json_code_style_violation_reporter.dart';
1751

18-
/// Style guide linter.
52+
/// Code Style Violations Checker.
1953
///
20-
/// Verify a coding style guide against a project.
54+
/// Check a coding style guide against a project.
2155
abstract class CodeStyleViolationsChecker {
2256
/// style guide to verify.
2357
final File styleGuide;
@@ -29,7 +63,7 @@ abstract class CodeStyleViolationsChecker {
2963
final CodeStyleViolationsParser parser;
3064

3165
/// Report founded style check violations.
32-
final CodeStylesViolationsReporter reporter;
66+
final CodeStyleViolationsReporter reporter;
3367

3468
/// create a [CodeStyleViolationsChecker].
3569
///
@@ -40,12 +74,10 @@ abstract class CodeStyleViolationsChecker {
4074
/// [parser] to parse founded style guide violations.
4175
///
4276
/// [reporter] to report founded style guide violations.
43-
const CodeStyleViolationsChecker(
44-
this.styleGuide,
45-
this.projectDir,
46-
this.parser,
47-
this.reporter,
48-
);
77+
const CodeStyleViolationsChecker(this.styleGuide,
78+
this.projectDir,
79+
this.parser,
80+
this.reporter,);
4981

5082
/// Run the checker.
5183
Future<void> check() async {
@@ -64,18 +96,18 @@ abstract class CodeStyleViolationsChecker {
6496
Future<String> getCodeStyleViolations();
6597
}
6698

67-
/// Style guide violations reporter.
99+
/// Code style violations reporter.
68100
///
69-
/// Report style guide violations.
70-
abstract class CodeStylesViolationsReporter {
71-
/// Create a constant instance of a [CodeStylesViolationsReporter].
72-
const CodeStylesViolationsReporter();
101+
/// Report code style violations.
102+
abstract class CodeStyleViolationsReporter {
103+
/// Create a constant instance of a [CodeStyleViolationsReporter].
104+
const CodeStyleViolationsReporter();
73105

74106
/// Report [violations].
75107
Future<void> report(final List<CodeStyleViolation> violations);
76108
}
77109

78-
/// Style guide violation parser.
110+
/// Code style violations parser.
79111
///
80112
/// Parse founded violations.
81113
abstract class CodeStyleViolationsParser {
@@ -85,8 +117,6 @@ abstract class CodeStyleViolationsParser {
85117
/// Parse violations contained in the [violations].
86118
///
87119
/// [projectDir] the violations are coming from.
88-
Future<List<CodeStyleViolation>> parse(
89-
final String violations,
90-
final String projectDir,
91-
);
120+
Future<List<CodeStyleViolation>> parse(final String violations,
121+
final String projectDir,);
92122
}

lib/src/checkers/dart/dart_project_style_guide_checker.dart

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)