Skip to content

Commit 0403b55

Browse files
committed
Apply pedantic analysis options
1 parent afbce1a commit 0403b55

File tree

8 files changed

+63
-96
lines changed

8 files changed

+63
-96
lines changed

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![codecov](https://codecov.io/gh/arturdm/bitbucket_code_coverage/branch/master/graph/badge.svg)](https://codecov.io/gh/arturdm/bitbucket_code_coverage)
55

66
Converts coverage data from LCOV and publishes to Bitbucket server with
7-
[plugin](https://bitbucket.org/atlassian/bitbucket-code-coverage) installed.
7+
[Bitbucket Server Code Coverage Plugin] installed.
88

99
## Usage
1010

@@ -15,17 +15,29 @@ dev_dependencies:
1515
bitbucket_code_coverage: ^0.0.1
1616
```
1717
18-
Run the executable.
18+
Run the executable for a single coverage file.
1919
2020
```bash
2121
pub run bitbucket_code_coverage \
2222
--url http://localhost:7990 \
23-
-t TOKEN \
24-
-u USERNAME \
25-
-p PASSWORD \
23+
-u <username> \
24+
-p <password> \
2625
post \
27-
-c COMMIT_ID \
28-
-f LCOV_FILE \
29-
-d WORKING_DIRECTORY \
30-
--file-pattern **/lcov.info
26+
-c <commit_id> \
27+
-f build/lcov.info
3128
```
29+
30+
In order to publish data from multiple coverage files use `--file-pattern` option. If you would
31+
like to use [Personal Access Token] you can do so by passing it to `-t` option.
32+
33+
```bash
34+
pub run bitbucket_code_coverage \
35+
--url http://localhost:7990 \
36+
-t <personal_access_token> \
37+
post \
38+
-c <commit_id> \
39+
--file-pattern **/lcov.info
40+
```
41+
42+
[Bitbucket Server Code Coverage Plugin]: https://bitbucket.org/atlassian/bitbucket-code-coverage
43+
[Personal Access Token]: https://confluence.atlassian.com/bitbucketserver/personal-access-tokens-939515499.html

analysis_options.yaml

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,8 @@
11
analyzer:
2-
# Options: https://www.dartlang.org/guides/language/analysis-options
32
strong-mode:
4-
implicit-casts: true
5-
implicit-dynamic: true
3+
implicit-casts: false
4+
implicit-dynamic: false
5+
exclude:
6+
- "**/*.g.dart"
67

7-
linter:
8-
rules:
9-
# Error Rules
10-
- avoid_empty_else
11-
- cancel_subscriptions
12-
# - close_sinks
13-
- comment_references
14-
- control_flow_in_finally
15-
- empty_statements
16-
- hash_and_equals
17-
- invariant_booleans
18-
- iterable_contains_unrelated_type
19-
- list_remove_unrelated_type
20-
- literal_only_boolean_expressions
21-
- test_types_in_equals
22-
- throw_in_finally
23-
- unrelated_type_equality_checks
24-
- valid_regexps
25-
26-
# Style Rules
27-
- always_declare_return_types
28-
# - always_specify_types
29-
- annotate_overrides
30-
# - avoid_as
31-
- avoid_init_to_null
32-
- avoid_return_types_on_setters
33-
- await_only_futures
34-
- camel_case_types
35-
# - cascade_invocations
36-
- curly_braces_in_flow_control_structures
37-
- constant_identifier_names
38-
- empty_catches
39-
- empty_constructor_bodies
40-
- implementation_imports
41-
- library_names
42-
- library_prefixes
43-
- non_constant_identifier_names
44-
# - one_member_abstracts
45-
- only_throw_errors
46-
- overridden_fields
47-
- package_api_docs
48-
- package_prefixed_library_names
49-
- prefer_equal_for_default_values
50-
- prefer_is_not_empty
51-
# - parameter_assignments
52-
- prefer_final_fields
53-
# - prefer_final_locals
54-
# - public_member_api_docs
55-
- slash_for_doc_comments
56-
- sort_unnamed_constructors_first
57-
- type_annotate_public_apis
58-
- type_init_formals
59-
- unawaited_futures
60-
- unnecessary_brace_in_string_interps
61-
- unnecessary_getters_setters
8+
include: package:pedantic/analysis_options.yaml

lib/bitbucket_code_coverage_command_runner.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ class BitbucketCodeCoverageCommandRunner extends CommandRunner<Null> {
1010
"Converts and publishes coverage data to BitBucket server.") {
1111
argParser.addFlag("verbose",
1212
abbr: "v", negatable: false, help: "makes the output more verbose");
13-
argParser.addOption("url", help: "sets the Bitbucket server url");
13+
argParser.addOption("url", help: "sets the Bitbucket server url, e.g. http://localhost:7990");
1414
argParser.addOption("username", abbr: "u", help: "sets the username for Bitbucket server");
1515
argParser.addOption("password", abbr: "p", help: "sets the user password for Bitbucket server");
1616
argParser.addOption("token",
17-
abbr: "t",
18-
help: "sets the token for Bitbucket server (takes precedence over username and password)");
17+
abbr: "t", help: "sets the Personal Access Token for Bitbucket server");
1918
addCommand(PostCommand());
2019
}
2120

lib/client/coverage_converter/lcov/path_prefix_finder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PathPrefixFinder {
1212
return _parentPathsUntil(lcovDirectory, Directory(root))
1313
.firstWhere((FileSystemEntity entity) => existsSync(entity, sourceFilePath))
1414
.then((FileSystemEntity entity) => relative(entity, root))
15-
.catchError((_) => "");
15+
.catchError((Error _) => "");
1616
}
1717

1818
String relative(FileSystemEntity entity, String root) => p.relative(entity.path, from: root);

lib/client/model/coverage_string.dart

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import 'package:meta/meta.dart';
44

55
@immutable
66
class CoverageString {
7-
final List<int> covered;
8-
final List<int> partial;
9-
final List<int> uncovered;
7+
final Iterable<int> covered;
8+
final Iterable<int> partial;
9+
final Iterable<int> uncovered;
1010

11-
CoverageString({List<int> covered, List<int> partial, List<int> uncovered})
11+
CoverageString({Iterable<int> covered, Iterable<int> partial, Iterable<int> uncovered})
1212
: this.covered = List<int>.unmodifiable(covered ?? <int>[]),
1313
this.partial = List<int>.unmodifiable(partial ?? <int>[]),
1414
this.uncovered = List<int>.unmodifiable(uncovered ?? <int>[]);
@@ -20,23 +20,22 @@ class CoverageString {
2020

2121
@override
2222
bool operator ==(Object other) {
23-
Function equal = const ListEquality<int>().equals;
23+
const IterableEquality<int> equality = IterableEquality<int>();
2424
return identical(this, other) ||
2525
other is CoverageString &&
2626
runtimeType == other.runtimeType &&
27-
equal(covered, other.covered) &&
28-
equal(partial, other.partial) &&
29-
equal(uncovered, other.uncovered);
27+
equality.equals(covered, other.covered) &&
28+
equality.equals(partial, other.partial) &&
29+
equality.equals(uncovered, other.uncovered);
3030
}
3131

3232
@override
3333
int get hashCode => covered.hashCode ^ partial.hashCode ^ uncovered.hashCode;
3434

3535
factory CoverageString.fromString(String coverage) {
3636
List<String> split = coverage.split(";");
37-
Map<String, List<int>> lineMap = split
38-
.asMap()
39-
.map((_, String value) => MapEntry<String, List<int>>(_type(value), _lineNumbers(value)));
37+
Map<String, Iterable<int>> lineMap = split.asMap().map(
38+
(_, String value) => MapEntry<String, Iterable<int>>(_type(value), _lineNumbers(value)));
4039

4140
return CoverageString(covered: lineMap["C"], partial: lineMap["P"], uncovered: lineMap["U"]);
4241
}

lib/command/post/post_command.dart

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@ class PostCommand extends Command<Null> {
2222
@override
2323
String get name => "post";
2424

25-
String get coverageFilePath => argResults["file"];
25+
String get coverageFilePath => _fromArgResults("file");
2626

27-
String get coverageFilePattern => argResults["file-pattern"];
27+
String get coverageFilePattern => _fromArgResults("file-pattern");
2828

29-
String get workingDirectory => argResults["working-directory"];
29+
String get workingDirectory => _fromArgResults("working-directory");
3030

31-
String get commitId => argResults["commit-id"];
31+
String get commitId => _fromArgResults("commit-id");
3232

33-
String get url => globalResults["url"];
33+
String get url => _fromGlobalResults("url");
3434

35-
String get token => globalResults["token"];
35+
String get token => _fromGlobalResults("token");
3636

37-
String get username => globalResults["username"];
37+
String get username => _fromGlobalResults("username");
3838

39-
String get password => globalResults["password"];
39+
String get password => _fromGlobalResults("password");
40+
41+
T _fromArgResults<T>(String name) => argResults[name] as T;
42+
43+
T _fromGlobalResults<T>(String name) => globalResults[name] as T;
4044

4145
@override
4246
FutureOr<Null> run() async {

pubspec.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
name: bitbucket_code_coverage
22
version: 0.0.1
3+
description: >
4+
Converts coverage data from LCOV and publishes to Bitbucket server with
5+
https://bitbucket.org/atlassian/bitbucket-code-coverage plugin installed.
6+
authors:
7+
- Artur Stepniewski <[email protected]>
38
homepage: https://github.com/arturdm/bitbucket_code_coverage
4-
author: Artur Stepniewski <[email protected]>
59

610
environment:
711
sdk: ">=2.0.0 <3.0.0"
@@ -13,16 +17,18 @@ dependencies:
1317
args: ^1.4.1
1418
collection: ^1.14.11
1519
glob: ^1.1.7
16-
json_annotation: &json_version ^2.0.0
20+
http: ^0.12.0+1
21+
json_annotation: ^2.0.0
1722
lcov: ^4.1.0
1823
logging: ^0.11.3+2
24+
meta: ^1.1.7
1925
path: ^1.6.2
2026

2127
dev_dependencies:
2228
build_runner: ^1.0.0
23-
json_serializable: *json_version
29+
json_serializable: ^2.0.2
2430
mock_web_server: ^4.0.0
31+
pedantic: ^1.4.0
2532
test: ^1.5.3
2633
test_coverage: ^0.2.3
2734
test_descriptor: ^1.0.0
28-

test/integration/command/post/post_integration_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ void main() {
9494
])
9595
]);
9696
await dir.create();
97-
Map<String, dynamic> expectedRequestBody = {
98-
"files": [
97+
Map<String, Iterable<dynamic>> expectedRequestBody = {
98+
"files": <Map<String, String>>[
9999
{"path": "second/lib/first.dart", "coverage": "${lcov_factory.expectedCoverage()}"},
100100
{"path": "second/lib/second.dart", "coverage": "${lcov_factory.expectedCoverage()}"},
101101
{"path": "first/lib/first.dart", "coverage": "${lcov_factory.expectedCoverage()}"},

0 commit comments

Comments
 (0)