Skip to content

Commit f4ccd9d

Browse files
score up as Dart Package, part2 (#118)
* run pana * ignore unused_xxx * update analysis config for pana * fix ci * format * bump version * fix workflow * fix * mild fix * fix * mild fix * fix * fix version * fix version
1 parent 562807f commit f4ccd9d

15 files changed

Lines changed: 688 additions & 272 deletions

.github/workflows/dart_ci.yaml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ jobs:
2828
steps:
2929
- uses: actions/checkout@v2
3030
- uses: dart-lang/setup-dart@v1
31-
- name: dart format
32-
run: dart format ./ -l 120 --set-exit-if-changed
31+
- run: dart format . --set-exit-if-changed
3332

3433
analyze:
3534
runs-on: ubuntu-latest
@@ -39,8 +38,7 @@ jobs:
3938
- uses: dart-lang/setup-dart@v1
4039
- name: install dependencies
4140
run: dart pub get
42-
- name: analyzer
43-
run: dart analyze --fatal-infos --fatal-warnings .
41+
- run: dart analyze --fatal-infos --fatal-warnings .
4442

4543
test:
4644
needs: [format, analyze]
@@ -88,6 +86,22 @@ jobs:
8886
with:
8987
file: lcov.info
9088

89+
- name: run pana to chceck package score before publish
90+
if: runner.os == 'Linux'
91+
id: run_pana_step
92+
run: |
93+
pub_point_by_pana=$(dart run pana | tail -1)
94+
echo "::set-output name=pub_point_by_pana::$pub_point_by_pana"
95+
96+
- uses: Sibz/github-status-action@v1
97+
if: runner.os == 'Linux'
98+
with:
99+
authToken: ${{ secrets.GITHUB_TOKEN }}
100+
context: Pub Poits by Pana
101+
description: ${{ steps.run_pana_step.outputs.pub_point_by_pana }}
102+
state: success
103+
sha: ${{ github.event.pull_request.head.sha || github.sha }}
104+
91105
- name: run example
92106
run: |-
93107
cd example && dart pub get && cd ..

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.9.1
2+
3+
- follow Dart Package ecosystem changed. (See: https://github.com/sensuikan1973/libedax4dart/pull/118)
4+
15
# 2.9.0
26

37
- follow Dart Package ecosystem changed. (See: https://github.com/sensuikan1973/libedax4dart/pull/117)

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ dart example/example.dart
5050
#### format
5151

5252
```sh
53-
dart format --fix -l 120 .
53+
# fix with line length 80 for pana, although I don't like.
54+
# See: https://github.com/dart-lang/dart_style/issues/918
55+
dart format --fix .
5456
```
5557

5658
#### test
@@ -63,6 +65,14 @@ dart run test .
6365

6466
```sh
6567
dart analyze .
68+
69+
dart fix --apply # auto fix
70+
```
71+
72+
#### [pana](https://pub.dev/packages/pana)
73+
74+
```sh
75+
dart run pana
6676
```
6777

6878
#### document
@@ -81,8 +91,8 @@ libedax_build_command="make libbuild ARCH=x64-modern COMP=gcc OS=osx" dst="." ./
8191
#### generate bindings
8292

8393
```sh
84-
# Before this, you must run build_libedax.sh
85-
dart run ffigen --config ffigen.yaml --verbose severe && dart format --fix -l 120 .
94+
# Before this, you must run build_libedax.sh.
95+
dart run ffigen --config ffigen.yaml --verbose severe && dart format --fix .
8696
```
8797

8898
### reference

example/example.dart

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import 'package:libedax4dart/libedax4dart.dart';
44

55
void main() {
66
// initialize
7-
const initParams = ['', '-book-file', './resources/test_book.dat', '-level', '16'];
7+
const initParams = [
8+
'',
9+
'-book-file',
10+
'./resources/test_book.dat',
11+
'-level',
12+
'16'
13+
];
814
final edax = LibEdax()
915
..libedaxInitialize(initParams)
1016
..edaxInit();
@@ -23,8 +29,12 @@ void main() {
2329
/// get hints
2430
final hintList = edax.edaxHint(2);
2531
stdout
26-
..writeln('1st move: ${hintList.first.moveString}, ${hintList.first.scoreString}')
27-
..writeln('2nd move: ${hintList[1].moveString}, ${hintList[1].scoreString}');
32+
..writeln(
33+
'1st move: ${hintList.first.moveString}, ${hintList.first.scoreString}',
34+
)
35+
..writeln(
36+
'2nd move: ${hintList[1].moveString}, ${hintList[1].scoreString}',
37+
);
2838

2939
// NOTE: If you use another command, See: https://sensuikan1973.github.io/libedax4dart/libedax4dart/LibEdax-class.html
3040
}

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ packages:
8484
path: ".."
8585
relative: true
8686
source: path
87-
version: "2.9.0"
87+
version: "2.9.1"
8888
meta:
8989
dependency: transitive
9090
description:

example/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: libedax4dart_example
2-
version: 2.9.0-example
2+
version: 2.9.1-example
33
publish_to: none
44

55
environment:

ffigen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ output: 'lib/src/ffi/bindings.dart'
55
sort: true
66
# See: https://github.com/dart-lang/pana/issues/1013
77
# See: https://dart.dev/guides/language/analysis-options#excluding-code-from-analysis
8-
preamble: "// ignore_for_file: type=lint"
8+
preamble: "// ignore_for_file: type=lint, unused_element, unused_field"
99
headers:
1010
entry-points:
1111
- 'edax-reversi/src/all.c'

lib/src/board.dart

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,25 @@ class Board {
2323
List<int> get squaresOfPlayer => _squares(player);
2424

2525
/// square String list of player's bitboard.
26-
List<String> get squareStringsOfPlayer => _squares(player).map(move2String).toList();
26+
List<String> get squareStringsOfPlayer =>
27+
_squares(player).map(move2String).toList();
2728

2829
/// square list of opponent's bitboard.
2930
List<int> get squaresOfOpponent => _squares(opponent);
3031

3132
/// square String list of opponent's bitboard.
32-
List<String> get squareStringsOfOpponent => _squares(opponent).map(move2String).toList();
33+
List<String> get squareStringsOfOpponent =>
34+
_squares(opponent).map(move2String).toList();
3335

3436
List<int> _squares(final int bitboard) {
3537
final result = <int>[];
3638
final target = BigInt.from(bitboard).toUnsigned(64);
3739
var mask = BigInt.from(0x8000000000000000).toUnsigned(64);
3840
var i = 0;
3941
while (i <= 63) {
40-
if ((mask & target) == mask) result.add(63 - i); // NOTE: head of edax bitboard is "h8".
42+
if ((mask & target) == mask) {
43+
result.add(63 - i);
44+
} // NOTE: head of edax bitboard is "h8".
4145
mask = mask >> 1;
4246
i++;
4347
}
@@ -58,8 +62,10 @@ class Board {
5862
///
5963
/// e.g. `-------------------*-------**O----**O*-----O--------------------W`.
6064
String stringApplicableToSetboard(final int currentColor) {
61-
final pStone = currentColor == TurnColor.black ? ColorChar.black : ColorChar.white;
62-
final oStone = currentColor == TurnColor.black ? ColorChar.white : ColorChar.black;
65+
final pStone =
66+
currentColor == TurnColor.black ? ColorChar.black : ColorChar.white;
67+
final oStone =
68+
currentColor == TurnColor.black ? ColorChar.white : ColorChar.black;
6369

6470
final buffer = StringBuffer();
6571
for (var k = 0; k < 8; k++) {
@@ -93,8 +99,10 @@ class Board {
9399
/// 8 - - - - - - - - 8 <br>
94100
/// A B C D E F G H
95101
String prettyString(final int currentColor) {
96-
final pStone = currentColor == TurnColor.black ? ColorChar.black : ColorChar.white;
97-
final oStone = currentColor == TurnColor.black ? ColorChar.white : ColorChar.black;
102+
final pStone =
103+
currentColor == TurnColor.black ? ColorChar.black : ColorChar.white;
104+
final oStone =
105+
currentColor == TurnColor.black ? ColorChar.white : ColorChar.black;
98106

99107
final buffer = StringBuffer()..writeln(' A B C D E F G H');
100108
for (var k = 0; k < 8; k++) {

0 commit comments

Comments
 (0)