From f3fbc80f8e55efe406150ee07072b8ae4fcd2ca0 Mon Sep 17 00:00:00 2001 From: Aleksey Kulikov Date: Fri, 22 Oct 2021 17:25:06 +0300 Subject: [PATCH] style: no implicit casts and dynamic --- analysis_options.yaml | 3 +++ lib/src/bindings/checkout.dart | 6 ++--- lib/src/bindings/revparse.dart | 2 +- lib/src/bindings/stash.dart | 4 ++-- lib/src/oid.dart | 40 ++++++++++++++++++++-------------- lib/src/repository.dart | 4 ++-- lib/src/revparse.dart | 6 +++-- test/branch_test.dart | 2 +- test/config_test.dart | 6 ++--- test/revwalk_test.dart | 2 +- test/worktree_test.dart | 10 ++++----- 11 files changed, 49 insertions(+), 36 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index cc78928..cfa814e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -6,5 +6,8 @@ linter: - directives_ordering - lines_longer_than_80_chars analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false exclude: - lib/src/bindings/libgit2_bindings.dart diff --git a/lib/src/bindings/checkout.dart b/lib/src/bindings/checkout.dart index e22e87b..84355e6 100644 --- a/lib/src/bindings/checkout.dart +++ b/lib/src/bindings/checkout.dart @@ -37,7 +37,7 @@ void head({ ); for (final p in pathPointers as List) { - calloc.free(p); + calloc.free(p as Pointer); } calloc.free(strArray as Pointer); calloc.free(optsC); @@ -72,7 +72,7 @@ void index({ ); for (final p in pathPointers as List) { - calloc.free(p); + calloc.free(p as Pointer); } calloc.free(strArray as Pointer); calloc.free(optsC); @@ -109,7 +109,7 @@ void tree({ ); for (final p in pathPointers as List) { - calloc.free(p); + calloc.free(p as Pointer); } calloc.free(strArray as Pointer); calloc.free(optsC); diff --git a/lib/src/bindings/revparse.dart b/lib/src/bindings/revparse.dart index 096be07..7da1676 100644 --- a/lib/src/bindings/revparse.dart +++ b/lib/src/bindings/revparse.dart @@ -91,7 +91,7 @@ List revParseExt({ calloc.free(referenceOut); throw LibGit2Error(libgit2.git_error_last()); } else { - var result = []; + var result = []; result.add(objectOut.value); if (referenceOut.value != nullptr) { result.add(referenceOut.value); diff --git a/lib/src/bindings/stash.dart b/lib/src/bindings/stash.dart index 357953d..a8ba24b 100644 --- a/lib/src/bindings/stash.dart +++ b/lib/src/bindings/stash.dart @@ -70,7 +70,7 @@ void apply({ final error = libgit2.git_stash_apply(repoPointer, index, options); for (final p in pathPointers as List) { - calloc.free(p); + calloc.free(p as Pointer); } calloc.free(strArray as Pointer); calloc.free(optsC); @@ -125,7 +125,7 @@ void pop({ final error = libgit2.git_stash_pop(repoPointer, index, options); for (final p in pathPointers as List) { - calloc.free(p); + calloc.free(p as Pointer); } calloc.free(strArray as Pointer); calloc.free(optsC); diff --git a/lib/src/oid.dart b/lib/src/oid.dart index f58b789..e626d6a 100644 --- a/lib/src/oid.dart +++ b/lib/src/oid.dart @@ -58,28 +58,36 @@ class Oid { 0); } - bool operator <(other) { - return (other is Oid) && - (bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) == - -1); + bool operator <(Oid other) { + return bindings.compare( + aPointer: _oidPointer, + bPointer: other._oidPointer, + ) == + -1; } - bool operator <=(other) { - return (other is Oid) && - (bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) == - -1); + bool operator <=(Oid other) { + return bindings.compare( + aPointer: _oidPointer, + bPointer: other._oidPointer, + ) == + -1; } - bool operator >(other) { - return (other is Oid) && - (bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) == - 1); + bool operator >(Oid other) { + return bindings.compare( + aPointer: _oidPointer, + bPointer: other._oidPointer, + ) == + 1; } - bool operator >=(other) { - return (other is Oid) && - (bindings.compare(aPointer: _oidPointer, bPointer: other._oidPointer) == - 1); + bool operator >=(Oid other) { + return bindings.compare( + aPointer: _oidPointer, + bPointer: other._oidPointer, + ) == + 1; } @override // coverage:ignore-line diff --git a/lib/src/repository.dart b/lib/src/repository.dart index ad2f8aa..4275aec 100644 --- a/lib/src/repository.dart +++ b/lib/src/repository.dart @@ -648,7 +648,7 @@ class Repository { Index revertCommit({ required Commit revertCommit, required Commit ourCommit, - mainline = 0, + int mainline = 0, }) { return Index(commit_bindings.revertCommit( repoPointer: _repoPointer, @@ -986,7 +986,7 @@ class Repository { head.free(); ref.free(); - return [analysisSet, mergePreference]; + return [analysisSet, mergePreference]; } /// Merges the given commit [oid] into HEAD, writing the results into the diff --git a/lib/src/revparse.dart b/lib/src/revparse.dart index c8d0860..8cbcef6 100644 --- a/lib/src/revparse.dart +++ b/lib/src/revparse.dart @@ -23,9 +23,11 @@ class RevParse { repoPointer: repo.pointer, spec: spec, ); - object = Commit(pointers[0].cast()); + object = Commit(pointers[0].cast() as Pointer); if (pointers.length == 2) { - reference = Reference(pointers[1].cast()); + reference = Reference( + pointers[1].cast() as Pointer, + ); } else { reference = null; } diff --git a/test/branch_test.dart b/test/branch_test.dart index 10f16ef..7dbfd87 100644 --- a/test/branch_test.dart +++ b/test/branch_test.dart @@ -46,7 +46,7 @@ void main() { }); test('returns a list of remote branches', () { - expect(repo.branchesRemote, []); + expect(repo.branchesRemote, []); }); test('throws when trying to return list and error occurs', () { diff --git a/test/config_test.dart b/test/config_test.dart index 2fd424a..d54e17a 100644 --- a/test/config_test.dart +++ b/test/config_test.dart @@ -199,7 +199,7 @@ void main() { }); test('returns empty list if multivar not found', () { - expect(config.multivar(variable: 'not.there'), []); + expect(config.multivar(variable: 'not.there'), []); }); }); @@ -249,7 +249,7 @@ void main() { variable: 'core.gitproxy', regexp: 'for kernel.org\$', ), - [], + [], ); }); @@ -265,7 +265,7 @@ void main() { config.deleteMultivar(variable: 'core.gitproxy', regexp: ''); - expect(config.multivar(variable: 'core.gitproxy'), []); + expect(config.multivar(variable: 'core.gitproxy'), []); }); }); diff --git a/test/revwalk_test.dart b/test/revwalk_test.dart index b3a1721..4731606 100644 --- a/test/revwalk_test.dart +++ b/test/revwalk_test.dart @@ -148,7 +148,7 @@ void main() { walker.reset(); final commits = walker.walk(); - expect(commits, []); + expect(commits, []); walker.free(); }); diff --git a/test/worktree_test.dart b/test/worktree_test.dart index 0a2b84c..6799c02 100644 --- a/test/worktree_test.dart +++ b/test/worktree_test.dart @@ -30,7 +30,7 @@ void main() { group('Worktree', () { test('successfully creates worktree at provided path', () { - expect(repo.worktrees, []); + expect(repo.worktrees, []); final worktree = repo.createWorktree( name: worktreeName, @@ -58,7 +58,7 @@ void main() { final head = repo.revParseSingle('HEAD'); final worktreeBranch = repo.createBranch(name: 'v1', target: head); final ref = repo.lookupReference('refs/heads/v1'); - expect(repo.worktrees, []); + expect(repo.worktrees, []); final worktree = repo.createWorktree( name: worktreeName, @@ -75,7 +75,7 @@ void main() { worktreeDir.deleteSync(recursive: true); worktree.prune(); - expect(repo.worktrees, []); + expect(repo.worktrees, []); expect(worktreeBranch.isCheckedOut, false); expect(branches.any((branch) => branch.name == 'v1'), true); @@ -162,7 +162,7 @@ void main() { }); test('successfully prunes worktree', () { - expect(repo.worktrees, []); + expect(repo.worktrees, []); final worktree = repo.createWorktree( name: worktreeName, @@ -177,7 +177,7 @@ void main() { expect(worktree.isValid, false); worktree.prune(); - expect(repo.worktrees, []); + expect(repo.worktrees, []); worktree.free(); });