Skip to content

Commit

Permalink
Merge pull request #3 from bitsydarel/update_release_pipeline
Browse files Browse the repository at this point in the history
Updated script to version 2.0.4 and added json reporter
  • Loading branch information
bitsydarel committed Jan 22, 2021
2 parents 78dd2fd + ca6d445 commit 381e631
Show file tree
Hide file tree
Showing 26 changed files with 1,067 additions and 337 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ name: Dart

on:
push:
branches:
# Push events to branches matching refs/heads/releases/[version]
- 'release/**'
tags:
- 'v*'

jobs:
build:
Expand Down Expand Up @@ -48,20 +47,22 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Get the tag name
id: get_tag_name
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}

- name: Create a Release
id: create_release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# The name of the tag. This should come from the webhook payload, `github.GITHUB_REF` when a user pushes a new tag
tag_name: ${{ github.ref }}
tag_name: ${{ steps.get_tag_name.outputs.TAG_NAME }}
# The name of the release. For example, `Release v1.0.1`
release_name: Release ${{ github.ref }}
release_name: Release ${{ steps.get_tag_name.outputs.TAG_NAME }}
# Path to file with information about the tag.
body_path: CHANGELOG.md # optional


release-linux:
needs: [ release ]

Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@

## 2.0.3

- code cleanup and improvement
- code cleanup and improvement

## 2.0.4

- Added new reporter for json

- Cleanup code and documentation
48 changes: 40 additions & 8 deletions bin/dbstyleguidechecker.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
/*
* BSD 3-Clause License
*
* Copyright (c) 2020, Bitsy Darel
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

import 'dart:async';
import 'dart:io';

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

try {
final CodeStylesViolationsReporter reporter =
final CodeStyleViolationsReporter reporter =
_createReporter(scriptArgument);

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

CodeStyleViolationsChecker _createChecker(
final ScriptArgument scriptArgument,
final CodeStylesViolationsReporter reporter,
final CodeStyleViolationsReporter reporter,
) {
switch (scriptArgument.projectType) {
case dartProjectType:
Expand All @@ -81,31 +114,29 @@ CodeStyleViolationsChecker _createChecker(
default:
throw UnrecoverableException(
'Invalid project type specified, '
"supported are ${supportedProjectType.join(", ")}",
"supported are ${supportedProjectType.join(", ")}",
exitInvalidArgument,
);
}
}

CodeStylesViolationsReporter _createReporter(
CodeStyleViolationsReporter _createReporter(
final ScriptArgument scriptArgument,
) {
switch (scriptArgument.reporterType) {
case reporterOfTypeConsole:
return const ConsoleCodeStyleViolationsReporter();
break;
case reporterOfTypeFile:
final File reporterOutputFile = scriptArgument.reporterOutputFile;

if (reporterOutputFile == null) {
throw const UnrecoverableException(
"Reporter of type 'file' specified "
'but reporter output file not specified.',
'but reporter output file not specified.',
exitMissingRequiredArgument,
);
}
return FileCodeStyleViolationsReporter(reporterOutputFile);
break;
case reporterOfTypeGithub:
final VcsArgument vcs = scriptArgument.vcs;

Expand All @@ -122,7 +153,8 @@ CodeStylesViolationsReporter _createReporter(
vcs.pullRequestId,
vcs.accessToken,
);
break;
case reporterOfTypeJson:
return const JsonCodeStyleViolationReporter();
default:
throw const UnrecoverableException(
'Invalid reporter type provided or not supported',
Expand Down
33 changes: 33 additions & 0 deletions example/lib/example.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
/*
* BSD 3-Clause License
*
* Copyright (c) 2020, Bitsy Darel
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

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

library dbstyleguidechecker;

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

import 'package:dbstyleguidechecker/src/style_guide_violation.dart';
import 'package:dbstyleguidechecker/src/code_style_violation.dart';

export 'package:dbstyleguidechecker/src/checkers/dart/dart_project_style_guide_checker.dart';
export 'package:dbstyleguidechecker/src/checkers/dart/flutter_project_style_guide_checker.dart';
export 'package:dbstyleguidechecker/src/checkers/dart_project_style_guide_checker.dart';
export 'package:dbstyleguidechecker/src/checkers/flutter_project_style_guide_checker.dart';
export 'package:dbstyleguidechecker/src/reporters/console_code_style_violations_reporter.dart';
export 'package:dbstyleguidechecker/src/reporters/github/github_pull_request_style_guide_check_reporter.dart';
export 'package:dbstyleguidechecker/src/reporters/file_style_guide_violation_reporter.dart';
export 'package:dbstyleguidechecker/src/parsers/dart/dart_analyzer_violation_parser.dart';
export 'package:dbstyleguidechecker/src/reporters/file_code_style_violation_reporter.dart';
export 'package:dbstyleguidechecker/src/parsers/dart_analyzer_violation_parser.dart';
export 'package:dbstyleguidechecker/src/exceptions.dart';
export 'package:dbstyleguidechecker/src/utils/script_utils.dart';
export 'package:dbstyleguidechecker/src/reporters/github/github_utils.dart';
export 'package:dbstyleguidechecker/src/reporters/json_code_style_violation_reporter.dart';

/// Style guide linter.
/// Code Style Violations Checker.
///
/// Verify a coding style guide against a project.
/// Check a coding style guide against a project.
abstract class CodeStyleViolationsChecker {
/// style guide to verify.
final File styleGuide;
Expand All @@ -29,7 +63,7 @@ abstract class CodeStyleViolationsChecker {
final CodeStyleViolationsParser parser;

/// Report founded style check violations.
final CodeStylesViolationsReporter reporter;
final CodeStyleViolationsReporter reporter;

/// create a [CodeStyleViolationsChecker].
///
Expand All @@ -40,12 +74,10 @@ abstract class CodeStyleViolationsChecker {
/// [parser] to parse founded style guide violations.
///
/// [reporter] to report founded style guide violations.
const CodeStyleViolationsChecker(
this.styleGuide,
this.projectDir,
this.parser,
this.reporter,
);
const CodeStyleViolationsChecker(this.styleGuide,
this.projectDir,
this.parser,
this.reporter,);

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

/// Style guide violations reporter.
/// Code style violations reporter.
///
/// Report style guide violations.
abstract class CodeStylesViolationsReporter {
/// Create a constant instance of a [CodeStylesViolationsReporter].
const CodeStylesViolationsReporter();
/// Report code style violations.
abstract class CodeStyleViolationsReporter {
/// Create a constant instance of a [CodeStyleViolationsReporter].
const CodeStyleViolationsReporter();

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

/// Style guide violation parser.
/// Code style violations parser.
///
/// Parse founded violations.
abstract class CodeStyleViolationsParser {
Expand All @@ -85,8 +117,6 @@ abstract class CodeStyleViolationsParser {
/// Parse violations contained in the [violations].
///
/// [projectDir] the violations are coming from.
Future<List<CodeStyleViolation>> parse(
final String violations,
final String projectDir,
);
Future<List<CodeStyleViolation>> parse(final String violations,
final String projectDir,);
}
60 changes: 0 additions & 60 deletions lib/src/checkers/dart/dart_project_style_guide_checker.dart

This file was deleted.

Loading

0 comments on commit 381e631

Please sign in to comment.