Skip to content

Commit

Permalink
Linter fixes. Bump to 2.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sethloco committed May 3, 2022
1 parent 1a9ab3a commit 15afc3c
Show file tree
Hide file tree
Showing 61 changed files with 459 additions and 484 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.0.4

- Enhanced Android library resolution (special thanks to [mejdi14](https://github.com/mejdi14) for providing this).
- Linter updates and code cleanup

## 2.0.3

- Updated [prebuilt libraries](lib/src/zstd/blobs) to [ZSTD v1.5.0](https://github.com/facebook/zstd/releases/tag/v1.5.0).
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2021, Seth Berman (Instantiations, Inc)
Copyright (c) 2022, Seth Berman (Instantiations, Inc)
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
62 changes: 59 additions & 3 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml
include: package:lints/recommended.yaml

analyzer:
strong-mode:
Expand All @@ -17,5 +17,61 @@ analyzer:

linter:
rules:
# in conflict with effective-dart rules
avoid_types_on_closure_parameters: false
- avoid_catching_errors
- avoid_dynamic_calls
- avoid_function_literals_in_foreach_calls
- avoid_private_typedef_functions
- avoid_renaming_method_parameters
- avoid_returning_null_for_void
- avoid_unused_constructor_parameters
- avoid_void_async
- await_only_futures
- camel_case_types
- cancel_subscriptions
- comment_references
- constant_identifier_names
- control_flow_in_finally
- directives_ordering
- empty_statements
- file_names
- hash_and_equals
- implementation_imports
- iterable_contains_unrelated_type
- join_return_with_assignment
- lines_longer_than_80_chars
- list_remove_unrelated_type
- missing_whitespace_between_adjacent_strings
- no_runtimeType_toString
- non_constant_identifier_names
- only_throw_errors
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_asserts_in_initializer_lists
- prefer_const_constructors
- prefer_const_declarations
- prefer_expression_function_bodies
- prefer_final_locals
- prefer_function_declarations_over_variables
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_interpolation_to_compose_strings
- prefer_is_not_operator
- prefer_null_aware_operators
- prefer_relative_imports
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- provide_deprecation_message
- sort_pub_dependencies
- test_types_in_equals
- throw_in_finally
- unnecessary_brace_in_string_interps
- unnecessary_lambdas
- unnecessary_null_aware_assignments
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_string_interpolations
- use_string_buffers
- void_checks
65 changes: 30 additions & 35 deletions benchmark/brotli_benchmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// file for details. All rights reserved. Use of this source code is governed by
// a BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:benchmark_harness/benchmark_harness.dart';
import 'package:collection/collection.dart';
import 'package:es_compression/brotli.dart';
import 'package:es_compression/framework.dart';

import 'utils/benchmark_utils.dart';

/// An [BrotliEncodeBenchmark] calls [BrotliCodec.encode] on the incoming data
/// An [BrotliEncodeBenchmark] calls [BrotliCodec.encode()] on the incoming data
/// supplied by [BrotliData].
///
/// [warmup] is used to store of the encoded result.
Expand Down Expand Up @@ -48,7 +46,7 @@ class BrotliEncodeBenchmark extends BenchmarkBase {
}
}

/// An [BrotliDecodeBenchmark] calls [BrotliCodec.decode] on the incoming data
/// An [BrotliDecodeBenchmark] calls [BrotliCodec.decode()] on the incoming data
/// supplied by [BrotliData].
///
/// [warmup] is used to store of the decoded result.
Expand Down Expand Up @@ -102,37 +100,34 @@ class BrotliData {
Future<int> main(List<String> arguments) async {
final dataLength =
arguments.isEmpty ? 50 * 1024 * 1024 : int.parse(arguments.first);
exitCode = await _runBrotliBenchmark(dataLength);
return exitCode;
return await _runBrotliBenchmark(dataLength);
}

/// Brotli Benchmark which answers 0 on success, -1 on error
Future<int> _runBrotliBenchmark(int dataLength) async {
return Future(() {
print('generating $dataLength bytes of random data');
final bytes = generateRandomBytes(dataLength);
final emitter = CodecPerformanceEmitter(bytes.length);

print('Brotli encode/decode ${bytes.length} bytes of random data.');
var data = BrotliData(bytes);
BrotliEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
BrotliDecodeBenchmark(data, emitter: emitter).report();
var bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
if (bytesMatch != true) return -1;

print('');
print('generating ${bytes.length} bytes of constant data');
bytes.fillRange(0, bytes.length, 1);

print('Brotli encode/decode ${bytes.length} bytes of constant data.');
data = BrotliData(bytes);
BrotliEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
BrotliDecodeBenchmark(data, emitter: emitter).report();
bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
return (bytesMatch != true) ? -1 : 0;
});
}
Future<int> _runBrotliBenchmark(int dataLength) async => Future(() {
print('generating $dataLength bytes of random data');
final bytes = generateRandomBytes(dataLength);
final emitter = CodecPerformanceEmitter(bytes.length);

print('Brotli encode/decode ${bytes.length} bytes of random data.');
var data = BrotliData(bytes);
BrotliEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
BrotliDecodeBenchmark(data, emitter: emitter).report();
var bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
if (bytesMatch != true) return -1;

print('');
print('generating ${bytes.length} bytes of constant data');
bytes.fillRange(0, bytes.length, 1);

print('Brotli encode/decode ${bytes.length} bytes of constant data.');
data = BrotliData(bytes);
BrotliEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
BrotliDecodeBenchmark(data, emitter: emitter).report();
bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
return (bytesMatch != true) ? -1 : 0;
});
74 changes: 32 additions & 42 deletions benchmark/gzip_benchmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import 'dart:io';

import 'package:benchmark_harness/benchmark_harness.dart';
import 'package:collection/collection.dart';
import 'package:es_compression/framework.dart';

import 'utils/benchmark_utils.dart';

/// An [GZipEncodeBenchmark] calls [GZipCodec.encode] on the incoming data
/// An [GZipEncodeBenchmark] calls [GZipCodec.encode()] on the incoming data
/// supplied by [GZipData].
///
/// [warmup] is used to store of the encoded result.
Expand All @@ -21,10 +20,7 @@ class GZipEncodeBenchmark extends BenchmarkBase {
final GZipCodec codec;
late List<int> encoded;

GZipEncodeBenchmark(this.data,
{ScoreEmitter emitter = const PrintEmitter(),
int inputBufferLength = CodecBufferHolder.autoLength,
int outputBufferLength = CodecBufferHolder.autoLength})
GZipEncodeBenchmark(this.data, {ScoreEmitter emitter = const PrintEmitter()})
: codec = GZipCodec(level: -1),
super('gzip encode()', emitter: emitter);

Expand All @@ -44,7 +40,7 @@ class GZipEncodeBenchmark extends BenchmarkBase {
}
}

/// An [GZipDecodeBenchmark] calls [GZipCodec.decode] on the incoming data
/// An [GZipDecodeBenchmark] calls [GZipCodec.decode()] on the incoming data
/// supplied by [GZipData].
///
/// [warmup] is used to store of the decoded result.
Expand All @@ -55,10 +51,7 @@ class GZipDecodeBenchmark extends BenchmarkBase {
final GZipCodec codec;
late List<int> decoded;

GZipDecodeBenchmark(this.data,
{ScoreEmitter emitter = const PrintEmitter(),
int inputBufferLength = CodecBufferHolder.autoLength,
int outputBufferLength = CodecBufferHolder.autoLength})
GZipDecodeBenchmark(this.data, {ScoreEmitter emitter = const PrintEmitter()})
: codec = GZipCodec(level: -1),
super('gzip decode()', emitter: emitter);

Expand Down Expand Up @@ -95,37 +88,34 @@ class GZipData {
Future<int> main(List<String> arguments) async {
final dataLength =
arguments.isEmpty ? 50 * 1024 * 1024 : int.parse(arguments.first);
exitCode = await _runGZipBenchmark(dataLength);
return exitCode;
return await _runGZipBenchmark(dataLength);
}

/// GZip Benchmark which answers 0 on success, -1 on error
Future<int> _runGZipBenchmark(int dataLength) async {
return Future(() {
print('generating $dataLength bytes of random data');
final bytes = generateRandomBytes(dataLength);
final emitter = CodecPerformanceEmitter(bytes.length);

print('GZip encode/decode ${bytes.length} bytes of random data.');
var data = GZipData(bytes);
GZipEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio:'
'${compressionRatio(bytes.length, data.bytes.length)}');
GZipDecodeBenchmark(data, emitter: emitter).report();
var bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
if (bytesMatch != true) return -1;

print('');
print('generating ${bytes.length} bytes of constant data');
bytes.fillRange(0, bytes.length, 1);

print('GZip encode/decode ${bytes.length} bytes of constant data.');
data = GZipData(bytes);
GZipEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
GZipDecodeBenchmark(data, emitter: emitter).report();
bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
return (bytesMatch != true) ? -1 : 0;
});
}
Future<int> _runGZipBenchmark(int dataLength) async => Future(() {
print('generating $dataLength bytes of random data');
final bytes = generateRandomBytes(dataLength);
final emitter = CodecPerformanceEmitter(bytes.length);

print('GZip encode/decode ${bytes.length} bytes of random data.');
var data = GZipData(bytes);
GZipEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio:'
'${compressionRatio(bytes.length, data.bytes.length)}');
GZipDecodeBenchmark(data, emitter: emitter).report();
var bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
if (bytesMatch != true) return -1;

print('');
print('generating ${bytes.length} bytes of constant data');
bytes.fillRange(0, bytes.length, 1);

print('GZip encode/decode ${bytes.length} bytes of constant data.');
data = GZipData(bytes);
GZipEncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
GZipDecodeBenchmark(data, emitter: emitter).report();
bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
return (bytesMatch != true) ? -1 : 0;
});
65 changes: 30 additions & 35 deletions benchmark/lz4_benchmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
// file for details. All rights reserved. Use of this source code is governed by
// a BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:benchmark_harness/benchmark_harness.dart';
import 'package:collection/collection.dart';
import 'package:es_compression/framework.dart';
import 'package:es_compression/lz4.dart';

import 'utils/benchmark_utils.dart';

/// An [Lz4EncodeBenchmark] calls [Lz4Codec.encode] on the incoming data
/// An [Lz4EncodeBenchmark] calls [Lz4Codec.encode()] on the incoming data
/// supplied by [Lz4Data].
///
/// [warmup] is used to store of the encoded result.
Expand Down Expand Up @@ -48,7 +46,7 @@ class Lz4EncodeBenchmark extends BenchmarkBase {
}
}

/// An [Lz4DecodeBenchmark] calls [Lz4Codec.decode] on the incoming data
/// An [Lz4DecodeBenchmark] calls [Lz4Codec.decode()] on the incoming data
/// supplied by [Lz4Data].
///
/// [warmup] is used to store of the decoded result.
Expand Down Expand Up @@ -102,37 +100,34 @@ class Lz4Data {
Future<int> main(List<String> arguments) async {
final dataLength =
arguments.isEmpty ? 50 * 1024 * 1024 : int.parse(arguments.first);
exitCode = await _runLz4Benchmark(dataLength);
return exitCode;
return await _runLz4Benchmark(dataLength);
}

/// Lz4 Benchmark which answers 0 on success, -1 on error
Future<int> _runLz4Benchmark(int dataLength) async {
return Future(() {
print('generating $dataLength bytes of random data');
final bytes = generateRandomBytes(dataLength);
final emitter = CodecPerformanceEmitter(bytes.length);

print('Lz4 encode/decode ${bytes.length} bytes of random data.');
var data = Lz4Data(bytes);
Lz4EncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
Lz4DecodeBenchmark(data, emitter: emitter).report();
var bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
if (bytesMatch != true) return -1;

print('');
print('generating ${bytes.length} bytes of constant data');
bytes.fillRange(0, bytes.length, 1);

print('Lz4 encode/decode ${bytes.length} bytes of constant data.');
data = Lz4Data(bytes);
Lz4EncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
Lz4DecodeBenchmark(data, emitter: emitter).report();
bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
return (bytesMatch != true) ? -1 : 0;
});
}
Future<int> _runLz4Benchmark(int dataLength) async => Future(() {
print('generating $dataLength bytes of random data');
final bytes = generateRandomBytes(dataLength);
final emitter = CodecPerformanceEmitter(bytes.length);

print('Lz4 encode/decode ${bytes.length} bytes of random data.');
var data = Lz4Data(bytes);
Lz4EncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
Lz4DecodeBenchmark(data, emitter: emitter).report();
var bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
if (bytesMatch != true) return -1;

print('');
print('generating ${bytes.length} bytes of constant data');
bytes.fillRange(0, bytes.length, 1);

print('Lz4 encode/decode ${bytes.length} bytes of constant data.');
data = Lz4Data(bytes);
Lz4EncodeBenchmark(data, emitter: emitter).report();
print('compression ratio: '
'${compressionRatio(bytes.length, data.bytes.length)}');
Lz4DecodeBenchmark(data, emitter: emitter).report();
bytesMatch = const ListEquality<int>().equals(bytes, data.bytes);
return (bytesMatch != true) ? -1 : 0;
});
Loading

0 comments on commit 15afc3c

Please sign in to comment.