mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-05 04:39:07 -04:00
style: stricter linting
This commit is contained in:
parent
d0f7746a01
commit
2eb50dec69
12 changed files with 47 additions and 27 deletions
|
@ -14,9 +14,12 @@ linter:
|
||||||
rules:
|
rules:
|
||||||
- always_use_package_imports
|
- always_use_package_imports
|
||||||
- avoid_bool_literals_in_conditional_expressions
|
- avoid_bool_literals_in_conditional_expressions
|
||||||
|
- avoid_double_and_int_checks
|
||||||
- avoid_dynamic_calls
|
- avoid_dynamic_calls
|
||||||
|
- avoid_equals_and_hash_code_on_mutable_classes
|
||||||
- avoid_escaping_inner_quotes
|
- avoid_escaping_inner_quotes
|
||||||
- avoid_field_initializers_in_const_classes
|
- avoid_field_initializers_in_const_classes
|
||||||
|
- avoid_js_rounded_ints
|
||||||
- avoid_positional_boolean_parameters
|
- avoid_positional_boolean_parameters
|
||||||
- avoid_print
|
- avoid_print
|
||||||
- avoid_redundant_argument_values
|
- avoid_redundant_argument_values
|
||||||
|
@ -28,27 +31,41 @@ linter:
|
||||||
- avoid_unused_constructor_parameters
|
- avoid_unused_constructor_parameters
|
||||||
- avoid_void_async
|
- avoid_void_async
|
||||||
- cast_nullable_to_non_nullable
|
- cast_nullable_to_non_nullable
|
||||||
|
- deprecated_consistency
|
||||||
- directives_ordering
|
- directives_ordering
|
||||||
- eol_at_end_of_file
|
- eol_at_end_of_file
|
||||||
- join_return_with_assignment
|
- join_return_with_assignment
|
||||||
- library_private_types_in_public_api
|
- library_private_types_in_public_api
|
||||||
- lines_longer_than_80_chars
|
- lines_longer_than_80_chars
|
||||||
|
- literal_only_boolean_expressions
|
||||||
- missing_whitespace_between_adjacent_strings
|
- missing_whitespace_between_adjacent_strings
|
||||||
|
- no_default_cases
|
||||||
- noop_primitive_operations
|
- noop_primitive_operations
|
||||||
|
- null_check_on_nullable_type_parameter
|
||||||
- omit_local_variable_types
|
- omit_local_variable_types
|
||||||
|
- one_member_abstracts
|
||||||
- parameter_assignments
|
- parameter_assignments
|
||||||
|
- prefer_asserts_in_initializer_lists
|
||||||
|
- prefer_asserts_with_message
|
||||||
- prefer_const_constructors
|
- prefer_const_constructors
|
||||||
- prefer_constructors_over_static_methods
|
- prefer_constructors_over_static_methods
|
||||||
- prefer_final_in_for_each
|
- prefer_final_in_for_each
|
||||||
- prefer_final_locals
|
- prefer_final_locals
|
||||||
- prefer_if_elements_to_conditional_expressions
|
- prefer_if_elements_to_conditional_expressions
|
||||||
|
- prefer_int_literals
|
||||||
- prefer_null_aware_method_calls
|
- prefer_null_aware_method_calls
|
||||||
- require_trailing_commas
|
- require_trailing_commas
|
||||||
- sort_constructors_first
|
- sort_constructors_first
|
||||||
- sort_pub_dependencies
|
- sort_pub_dependencies
|
||||||
- sort_unnamed_constructors_first
|
- sort_unnamed_constructors_first
|
||||||
|
- tighten_type_of_initializing_formals
|
||||||
- type_annotate_public_apis
|
- type_annotate_public_apis
|
||||||
- unawaited_futures
|
- unawaited_futures
|
||||||
|
- unnecessary_await_in_return
|
||||||
|
- unnecessary_parenthesis
|
||||||
|
- unnecessary_raw_strings
|
||||||
|
- use_is_even_rather_than_modulo
|
||||||
|
- use_late_for_private_fields_and_variables
|
||||||
- use_named_constants
|
- use_named_constants
|
||||||
- use_raw_strings
|
- use_raw_strings
|
||||||
- use_setters_to_change_properties
|
- use_setters_to_change_properties
|
||||||
|
|
|
@ -249,7 +249,7 @@ Pointer<git_reference> createDirect({
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
calloc.free(out);
|
calloc.free(out);
|
||||||
throw (LibGit2Error(libgit2.git_error_last()));
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
}
|
}
|
||||||
|
@ -309,7 +309,7 @@ Pointer<git_reference> createSymbolic({
|
||||||
|
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
calloc.free(out);
|
calloc.free(out);
|
||||||
throw (LibGit2Error(libgit2.git_error_last()));
|
throw LibGit2Error(libgit2.git_error_last());
|
||||||
} else {
|
} else {
|
||||||
return out.value;
|
return out.value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,12 +211,12 @@ class _ConfigIterator implements Iterator<ConfigEntry> {
|
||||||
/// Pointer to memory address for allocated config iterator.
|
/// Pointer to memory address for allocated config iterator.
|
||||||
final Pointer<git_config_iterator> _iteratorPointer;
|
final Pointer<git_config_iterator> _iteratorPointer;
|
||||||
|
|
||||||
ConfigEntry? _currentEntry;
|
late ConfigEntry _currentEntry;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
final entry = calloc<Pointer<git_config_entry>>();
|
final entry = calloc<Pointer<git_config_entry>>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConfigEntry get current => _currentEntry!;
|
ConfigEntry get current => _currentEntry;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool moveNext() {
|
bool moveNext() {
|
||||||
|
|
|
@ -394,12 +394,12 @@ class _IndexIterator implements Iterator<IndexEntry> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final Pointer<git_index> _indexPointer;
|
final Pointer<git_index> _indexPointer;
|
||||||
IndexEntry? _currentEntry;
|
late IndexEntry _currentEntry;
|
||||||
int _index = 0;
|
int _index = 0;
|
||||||
late final int count;
|
late final int count;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
IndexEntry get current => _currentEntry!;
|
IndexEntry get current => _currentEntry;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool moveNext() {
|
bool moveNext() {
|
||||||
|
|
|
@ -5,7 +5,9 @@ import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||||
import 'package:libgit2dart/src/bindings/odb.dart' as odb_bindings;
|
import 'package:libgit2dart/src/bindings/odb.dart' as odb_bindings;
|
||||||
import 'package:libgit2dart/src/bindings/oid.dart' as bindings;
|
import 'package:libgit2dart/src/bindings/oid.dart' as bindings;
|
||||||
import 'package:libgit2dart/src/util.dart';
|
import 'package:libgit2dart/src/util.dart';
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
@immutable
|
||||||
class Oid {
|
class Oid {
|
||||||
/// Initializes a new instance of [Oid] class from provided
|
/// Initializes a new instance of [Oid] class from provided
|
||||||
/// pointer to Oid object in memory.
|
/// pointer to Oid object in memory.
|
||||||
|
|
|
@ -280,21 +280,20 @@ class Reference {
|
||||||
/// Repository where a reference resides.
|
/// Repository where a reference resides.
|
||||||
Repository get owner => Repository(bindings.owner(_refPointer));
|
Repository get owner => Repository(bindings.owner(_refPointer));
|
||||||
|
|
||||||
@override
|
/// Compares two references.
|
||||||
bool operator ==(Object other) {
|
bool equals(Reference other) {
|
||||||
return (other is Reference) &&
|
return bindings.compare(
|
||||||
bindings.compare(
|
ref1Pointer: _refPointer,
|
||||||
ref1Pointer: _refPointer,
|
ref2Pointer: other._refPointer,
|
||||||
ref2Pointer: other._refPointer,
|
);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Compares two references.
|
||||||
|
bool notEquals(Reference other) => !equals(other);
|
||||||
|
|
||||||
/// Releases memory allocated for reference object.
|
/// Releases memory allocated for reference object.
|
||||||
void free() => bindings.free(_refPointer);
|
void free() => bindings.free(_refPointer);
|
||||||
|
|
||||||
@override // coverage:ignore-line
|
|
||||||
int get hashCode => _refPointer.address.hashCode; // coverage:ignore-line
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'Reference{name: $name, target: $target, type: $type, '
|
return 'Reference{name: $name, target: $target, type: $type, '
|
||||||
|
|
|
@ -129,12 +129,12 @@ class _RefLogIterator implements Iterator<RefLogEntry> {
|
||||||
/// Pointer to memory address for allocated reflog object.
|
/// Pointer to memory address for allocated reflog object.
|
||||||
final Pointer<git_reflog> _reflogPointer;
|
final Pointer<git_reflog> _reflogPointer;
|
||||||
|
|
||||||
RefLogEntry? _currentEntry;
|
late RefLogEntry _currentEntry;
|
||||||
int _index = 0;
|
int _index = 0;
|
||||||
late final int _count;
|
late final int _count;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
RefLogEntry get current => _currentEntry!;
|
RefLogEntry get current => _currentEntry;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool moveNext() {
|
bool moveNext() {
|
||||||
|
|
|
@ -4,7 +4,9 @@ import 'package:libgit2dart/libgit2dart.dart';
|
||||||
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
import 'package:libgit2dart/src/bindings/libgit2_bindings.dart';
|
||||||
import 'package:libgit2dart/src/bindings/signature.dart' as bindings;
|
import 'package:libgit2dart/src/bindings/signature.dart' as bindings;
|
||||||
import 'package:libgit2dart/src/util.dart';
|
import 'package:libgit2dart/src/util.dart';
|
||||||
|
import 'package:meta/meta.dart';
|
||||||
|
|
||||||
|
@immutable
|
||||||
class Signature {
|
class Signature {
|
||||||
/// Initializes a new instance of [Signature] class from provided pointer to
|
/// Initializes a new instance of [Signature] class from provided pointer to
|
||||||
/// signature object in memory.
|
/// signature object in memory.
|
||||||
|
|
|
@ -18,7 +18,7 @@ String getLibName() {
|
||||||
ext = 'dll';
|
ext = 'dll';
|
||||||
} else if (Platform.isMacOS) {
|
} else if (Platform.isMacOS) {
|
||||||
ext = 'dylib';
|
ext = 'dylib';
|
||||||
} else if (!(Platform.isLinux)) {
|
} else if (!Platform.isLinux) {
|
||||||
throw Exception('Unsupported platform.');
|
throw Exception('Unsupported platform.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ void main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('throws when trying to get odb and error occurs', () {
|
test('throws when trying to get odb and error occurs', () {
|
||||||
expect(() => Repository((nullptr)).odb, throwsA(isA<LibGit2Error>()));
|
expect(() => Repository(nullptr).odb, throwsA(isA<LibGit2Error>()));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('creates new odb with no backends', () {
|
test('creates new odb with no backends', () {
|
||||||
|
|
|
@ -166,7 +166,7 @@ void main() {
|
||||||
final duplicate = ref.duplicate();
|
final duplicate = ref.duplicate();
|
||||||
|
|
||||||
expect(repo.references.length, 6);
|
expect(repo.references.length, 6);
|
||||||
expect(duplicate, equals(ref));
|
expect(duplicate.equals(ref), true);
|
||||||
|
|
||||||
duplicate.free();
|
duplicate.free();
|
||||||
ref.free();
|
ref.free();
|
||||||
|
@ -519,10 +519,10 @@ void main() {
|
||||||
final ref2 = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
final ref2 = Reference.lookup(repo: repo, name: 'refs/heads/master');
|
||||||
final ref3 = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
final ref3 = Reference.lookup(repo: repo, name: 'refs/heads/feature');
|
||||||
|
|
||||||
expect(ref1 == ref2, true);
|
expect(ref1.equals(ref2), true);
|
||||||
expect(ref1 != ref2, false);
|
expect(ref1.notEquals(ref2), false);
|
||||||
expect(ref1 == ref3, false);
|
expect(ref1.equals(ref3), false);
|
||||||
expect(ref1 != ref3, true);
|
expect(ref1.notEquals(ref3), true);
|
||||||
|
|
||||||
ref1.free();
|
ref1.free();
|
||||||
ref2.free();
|
ref2.free();
|
||||||
|
|
|
@ -65,7 +65,7 @@ void main() {
|
||||||
var headParse = RevParse.ext(repo: repo, spec: 'master');
|
var headParse = RevParse.ext(repo: repo, spec: 'master');
|
||||||
|
|
||||||
expect(headParse.object.oid.sha, headSHA);
|
expect(headParse.object.oid.sha, headSHA);
|
||||||
expect(headParse.reference, masterRef);
|
expect(headParse.reference?.equals(masterRef), true);
|
||||||
expect(headParse.toString(), contains('RevParse{'));
|
expect(headParse.toString(), contains('RevParse{'));
|
||||||
|
|
||||||
masterRef.free();
|
masterRef.free();
|
||||||
|
@ -82,7 +82,7 @@ void main() {
|
||||||
headParse.object.oid.sha,
|
headParse.object.oid.sha,
|
||||||
'5aecfa0fb97eadaac050ccb99f03c3fb65460ad4',
|
'5aecfa0fb97eadaac050ccb99f03c3fb65460ad4',
|
||||||
);
|
);
|
||||||
expect(headParse.reference, featureRef);
|
expect(headParse.reference?.equals(featureRef), true);
|
||||||
|
|
||||||
featureRef.free();
|
featureRef.free();
|
||||||
headParse.object.free();
|
headParse.object.free();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue