Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
- Migrate to `lints`:
  - NOTE: some constants were renamed to lowercase camel case.
- Improved GitHub CI.
- Added browser tests.
- lints: ^1.0.1
- coverage: ^1.0.4
  • Loading branch information
gmpassos committed Apr 26, 2022
1 parent cfd0032 commit a0ff20b
Show file tree
Hide file tree
Showing 19 changed files with 380 additions and 340 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ on:

jobs:
build:

runs-on: ubuntu-latest

container:
image: google/dart:latest

steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1
- name: Dart version
run: |
dart --version
Expand All @@ -28,10 +25,17 @@ jobs:
run: dart analyze --fatal-infos --fatal-warnings .
- name: dependency_validator
run: dart run dependency_validator
- name: Run tests
run: dart test
- name: Run tests (VM)
run: dart test --platform vm
- name: Run tests (Chrome)
run: dart test --platform chrome
- name: dartdoc
run: dartdoc --no-generate-docs
- name: Generate coverage report
run: dart run test_cov
run: |
dart pub global activate coverage
dart run test --coverage=./coverage
dart pub global run coverage:format_coverage --packages=.packages --report-on=lib --lcov -o ./coverage/lcov.info -i ./coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 3.1.0

- Migrate to `lints`:
- NOTE: some constants were renamed to lowercase camel case.
- Improved GitHub CI.
- Added browser tests.
- lints: ^1.0.1
- coverage: ^1.0.4

## 3.0.8

- Fixed `ResourceContent` load with errors.
Expand Down
9 changes: 4 additions & 5 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# 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

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.

# Uncomment to specify additional rules.
# linter:
# rules:
# - camel_case_types

analyzer:
# analyzer:
# exclude:
# - path/to/excluded/files/**
64 changes: 31 additions & 33 deletions lib/src/collections.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class Dimension implements Comparable<Dimension> {
return null;
}

static final RegExp _REGEXP_NON_DIGIT =
static final RegExp _regexpNonDigit =
RegExp(r'\D', multiLine: false, caseSensitive: true);

/// Parsers [wh] String, trying to split with [delimiter] between 2 numbers
Expand All @@ -136,10 +136,10 @@ class Dimension implements Comparable<Dimension> {
var nextInt = nextC.isNotEmpty || isInt(nextC);

if (prevInt && nextInt) {
var idxPrev = prev.lastIndexOf(_REGEXP_NON_DIGIT);
var idxPrev = prev.lastIndexOf(_regexpNonDigit);
if (idxPrev >= 0) prev = prev.substring(idxPrev + 1);

var idxNext = next.indexOf(_REGEXP_NON_DIGIT);
var idxNext = next.indexOf(_regexpNonDigit);
if (idxNext >= 0) next = next.substring(0, idxNext);

params.add(prev);
Expand Down Expand Up @@ -602,7 +602,7 @@ MapEntry<String, V?>? getEntryIgnoreCase<V>(Map<String, V?> map, String? key) {
/// Gets a [map] value ignoring [key] case.
V? getIgnoreCase<V>(Map<String, V> map, String? key) {
var entry = getEntryIgnoreCase(map, key);
return entry != null ? entry.value : null;
return entry?.value;
}

/// Puts a [map] value ignoring [key] case.
Expand Down Expand Up @@ -650,8 +650,8 @@ List<Map>? asListOfMap(Object? o) {
}

var s = o.toString();
var map = parseFromInlineMap(s, _INLINE_PROPERTIES_DELIMITER_PAIRS,
_INLINE_PROPERTIES_DELIMITER_KEYS_VALUES);
var map = parseFromInlineMap(
s, _inlinePropertiesDelimiterPairs, _inlinePropertiesDelimiterKeysValues);
return [map!];
}

Expand Down Expand Up @@ -689,7 +689,7 @@ bool isListOfStrings(Iterable? list) {
if (list == null || list.isEmpty) return false;

for (var value in list) {
if (!(value is String)) return false;
if (value is! String) return false;
}

return true;
Expand Down Expand Up @@ -726,15 +726,15 @@ dynamic asTreeOfKeyString(Object? tree) {
}
}

final RegExp _toListOfStrings_delimiter = RegExp(r'\s+');
final RegExp _toListOfStringsDelimiter = RegExp(r'\s+');

/// Converts [s] to a [List<String>].
/// Converts any collection to a flat list of strings.
List<String> toFlatListOfStrings(Object? s,
{Pattern? delimiter, bool trim = true, bool ignoreEmpty = true}) {
if (s == null) return [];

delimiter ??= _toListOfStrings_delimiter;
delimiter ??= _toListOfStringsDelimiter;

List<String> list;

Expand Down Expand Up @@ -1096,7 +1096,7 @@ MapEntry<K, V?>? findKeyEntry<K, V>(Map? map, List<K>? keys,
/// [ignoreCase] If [true] ignores the case of the keys.
V? findKeyValue<K, V>(Map? map, List<K>? keys, [bool ignoreCase = false]) {
var entry = findKeyEntry<K, V>(map, keys, ignoreCase);
return entry != null ? entry.value : null;
return entry?.value;
}

/// Finds in [map] a value that is in key path [keyPath]
Expand Down Expand Up @@ -1148,7 +1148,7 @@ V? findKeyPathValue<V>(Map? map, String? keyPath,
/// [ignoreCase] If [true] ignores the case of the keys.
K? findKeyName<K, V>(Map? map, List<K>? keys, [bool ignoreCase = false]) {
var entry = findKeyEntry(map, keys, ignoreCase);
return entry != null ? entry.key : null;
return entry?.key;
}

/// Returns [true] if [s] is empty or null.
Expand Down Expand Up @@ -1280,16 +1280,16 @@ List<T>? parseFromInlineList<T>(String? s, Pattern delimiter,
return list;
}

final RegExp _INLINE_PROPERTIES_DELIMITER_PAIRS = RegExp(r'\s*;\s*');
final RegExp _INLINE_PROPERTIES_DELIMITER_KEYS_VALUES = RegExp(r'\s*[:=]\s*');
final RegExp _inlinePropertiesDelimiterPairs = RegExp(r'\s*;\s*');
final RegExp _inlinePropertiesDelimiterKeysValues = RegExp(r'\s*[:=]\s*');

/// Parses an inline properties, like inline CSS, to a [Map<String,String>].
Map<String, String>? parseFromInlineProperties(String s,
[StringMapper<String>? mapperKey,
StringMapper<String>? mapperValue,
Map<String, String>? def]) {
return parseFromInlineMap(s, _INLINE_PROPERTIES_DELIMITER_PAIRS,
_INLINE_PROPERTIES_DELIMITER_KEYS_VALUES, mapperKey, mapperValue, def);
return parseFromInlineMap(s, _inlinePropertiesDelimiterPairs,
_inlinePropertiesDelimiterKeysValues, mapperKey, mapperValue, def);
}

/// Parses [v] as [String].
Expand Down Expand Up @@ -1370,14 +1370,14 @@ MapEntry<String, String>? parseMapEntryOfStrings<K, V>(Object? e,
return MapEntry('${e[0]}', '${e[1]}');
} else {
var values = e.sublist(1);
return MapEntry('${e[0]}', '${values.join(',')}');
return MapEntry('${e[0]}', values.join(','));
}
} else {
delimiter ??= RegExp(r'\s*[,;:]\s*');
var s = parseString(e)!;
var list = split(s, delimiter, 2);
if (list.length == 2) {
return MapEntry('${list[0]}', '${list[1]}');
return MapEntry(list[0], list[1]);
} else {
var first = list.first;
if (first.length < s.length) {
Expand Down Expand Up @@ -1535,7 +1535,7 @@ void deepReplaceSetValues<T>(
var entries = set.toList();

for (var val in entries) {
var val2;
Object? val2;
if (filter(set, null, val)) {
val2 = replacer(set, null, val);
} else {
Expand Down Expand Up @@ -1808,47 +1808,47 @@ class MapProperties extends MapDelegate<String, dynamic> {
/// [def] The default value if [key] not found.
String? getPropertyAsStringTrimLC(String key, [String? def]) {
var val = getPropertyAsStringTrim(key, def);
return val != null ? val.toLowerCase() : null;
return val?.toLowerCase();
}

/// Finds a property with [keys]. Returns the value in lower case and trimmed.
///
/// [def] The default value if [keys] not found.
String? findPropertyAsStringTrimLC(List<String> keys, [String? def]) {
var val = findPropertyAsStringTrim(keys, def);
return val != null ? val.toLowerCase() : null;
return val?.toLowerCase();
}

/// Gets a property with [key]. Returns the value in upper case and trimmed.
///
/// [def] The default value if [key] not found.
String? getPropertyAsStringTrimUC(String key, [String? def]) {
var val = getPropertyAsStringTrim(key, def);
return val != null ? val.toUpperCase() : null;
return val?.toUpperCase();
}

/// Finds a property with [keys]. Returns the value in upper case and trimmed.
///
/// [def] The default value if [keys] not found.
String? findPropertyAsStringTrimUC(List<String> keys, [String? def]) {
var val = findPropertyAsStringTrim(keys, def);
return val != null ? val.toUpperCase() : null;
return val?.toUpperCase();
}

/// Gets a property with [key]. Returns the value trimmed.
///
/// [def] The default value if [key] not found.
String? getPropertyAsStringTrim(String key, [String? def]) {
var val = getPropertyAsString(key, def);
return val != null ? val.trim() : null;
return val?.trim();
}

/// Finds a property with [keys]. Returns the value trimmed.
///
/// [def] The default value if [keys] not found.
String? findPropertyAsStringTrim(List<String> keys, [String? def]) {
var val = findPropertyAsString(keys, def);
return val != null ? val.trim() : null;
return val?.trim();
}

/// Gets a property with [key]. Returns the value as [String].
Expand Down Expand Up @@ -2178,9 +2178,8 @@ class NNField<T> {
T _value;

NNField(this.defaultValue,
{bool deepHashcode = false, this.filter, this.resolver})
: deepHashcode = deepHashcode,
_value = defaultValue;
{this.deepHashcode = false, this.filter, this.resolver})
: _value = defaultValue;

/// The filed value as [T].
T get value => get();
Expand Down Expand Up @@ -2490,15 +2489,14 @@ class TreeReferenceMap<K, V> implements Map<K, V> {
final bool Function(K parent, K child, bool deep)? childChecker;

TreeReferenceMap(this.root,
{bool autoPurge = false,
{this.autoPurge = false,
bool keepPurgedKeys = false,
this.purgedEntriesTimeout,
this.maxPurgedEntries,
this.parentGetter,
this.childrenGetter,
this.childChecker})
: autoPurge = autoPurge,
keepPurgedEntries = keepPurgedKeys;
: keepPurgedEntries = keepPurgedKeys;

final Map<K, V> _map = {};

Expand Down Expand Up @@ -2550,7 +2548,7 @@ class TreeReferenceMap<K, V> implements Map<K, V> {
if (key == null) return subValues;

if (includePurgedEntries) {
_getSubValuesImpl_includePurgedEntries(key, subValues);
_getSubValuesImplIncludePurgedEntries(key, subValues);
} else {
_getSubValuesImpl(key, subValues);
}
Expand All @@ -2571,7 +2569,7 @@ class TreeReferenceMap<K, V> implements Map<K, V> {
}
}

void _getSubValuesImpl_includePurgedEntries(K key, List<V> subValues) {
void _getSubValuesImplIncludePurgedEntries(K key, List<V> subValues) {
var children = getChildrenOf(key);
if (children.isEmpty) return;

Expand All @@ -2580,7 +2578,7 @@ class TreeReferenceMap<K, V> implements Map<K, V> {
if (value != null) {
subValues.add(value);
} else {
_getSubValuesImpl_includePurgedEntries(child, subValues);
_getSubValuesImplIncludePurgedEntries(child, subValues);
}
}
}
Expand Down
Loading

0 comments on commit a0ff20b

Please sign in to comment.