Bump dependencies and fix lints (#527)
diff --git a/example/c_json/main.dart b/example/c_json/main.dart
index 99042eb..adbdac6 100644
--- a/example/c_json/main.dart
+++ b/example/c_json/main.dart
@@ -40,8 +40,8 @@
print('Json converted successfully');
} else {
print("Converted json doesn't match\n");
- print('Actual:\n' + dartJson.toString() + '\n');
- print('Expected:\n' + json.decode(jsonString).toString());
+ print('Actual:\n$dartJson\n');
+ print('Expected:\n${json.decode(jsonString)}');
}
}
diff --git a/example/c_json/pubspec.yaml b/example/c_json/pubspec.yaml
index 3f9c865..7b76a5c 100644
--- a/example/c_json/pubspec.yaml
+++ b/example/c_json/pubspec.yaml
@@ -14,7 +14,7 @@
dev_dependencies:
ffigen:
path: '../../'
- lints: ^1.0.1
+ lints: ^2.0.1
ffigen:
output: 'cjson_generated_bindings.dart'
diff --git a/example/libclang-example/pubspec.yaml b/example/libclang-example/pubspec.yaml
index ab3b75c..bff5a3c 100644
--- a/example/libclang-example/pubspec.yaml
+++ b/example/libclang-example/pubspec.yaml
@@ -12,7 +12,7 @@
dev_dependencies:
ffigen:
path: '../../'
- lints: ^1.0.1
+ lints: ^2.0.1
ffigen:
output: 'generated_bindings.dart'
diff --git a/example/shared_bindings/lib/generated/a_shared_b_gen.dart b/example/shared_bindings/lib/generated/a_shared_b_gen.dart
index fbf9c16..1a221f2 100644
--- a/example/shared_bindings/lib/generated/a_shared_b_gen.dart
+++ b/example/shared_bindings/lib/generated/a_shared_b_gen.dart
@@ -4,7 +4,7 @@
//
// Generated by `package:ffigen`.
import 'dart:ffi' as ffi;
-import 'package:shared_bindings/generated/base_gen.dart' as _imp1;
+import 'package:shared_bindings/generated/base_gen.dart' as imp1;
/// Bindings to `headers/a.h` with shared definitions from `headers/base.h`.
class NativeLibraryASharedB {
@@ -31,9 +31,9 @@
late final _a_func1 = _a_func1Ptr.asFunction<void Function()>();
void a_func2(
- _imp1.BaseStruct2 s,
- _imp1.BaseUnion2 u,
- _imp1.BaseTypedef2 t,
+ imp1.BaseStruct2 s,
+ imp1.BaseUnion2 u,
+ imp1.BaseTypedef2 t,
) {
return _a_func2(
s,
@@ -44,10 +44,10 @@
late final _a_func2Ptr = _lookup<
ffi.NativeFunction<
- ffi.Void Function(_imp1.BaseStruct2, _imp1.BaseUnion2,
- _imp1.BaseTypedef2)>>('a_func2');
+ ffi.Void Function(imp1.BaseStruct2, imp1.BaseUnion2,
+ imp1.BaseTypedef2)>>('a_func2');
late final _a_func2 = _a_func2Ptr.asFunction<
- void Function(_imp1.BaseStruct2, _imp1.BaseUnion2, _imp1.BaseTypedef2)>();
+ void Function(imp1.BaseStruct2, imp1.BaseUnion2, imp1.BaseTypedef2)>();
}
class A_Struct1 extends ffi.Struct {
diff --git a/example/shared_bindings/pubspec.yaml b/example/shared_bindings/pubspec.yaml
index b1b5cfd..fbe942e 100644
--- a/example/shared_bindings/pubspec.yaml
+++ b/example/shared_bindings/pubspec.yaml
@@ -8,8 +8,11 @@
sdk: '>=2.17.0 <4.0.0'
dependencies:
+ cli_util: ^0.4.0
ffi: ^2.0.1
+ path: ^1.8.0
+
dev_dependencies:
ffigen:
path: '../../'
- lints: ^1.0.1
+ lints: ^2.0.1
diff --git a/example/simple/pubspec.yaml b/example/simple/pubspec.yaml
index 2755554..33b93eb 100644
--- a/example/simple/pubspec.yaml
+++ b/example/simple/pubspec.yaml
@@ -12,7 +12,7 @@
dev_dependencies:
ffigen:
path: '../../'
- lints: ^1.0.1
+ lints: ^2.0.1
ffigen:
name: NativeLibrary
diff --git a/lib/src/code_generator/compound.dart b/lib/src/code_generator/compound.dart
index 70a1cd6..2c915a2 100644
--- a/lib/src/code_generator/compound.dart
+++ b/lib/src/code_generator/compound.dart
@@ -141,8 +141,8 @@
s.write('${m.name};\n\n');
} else {
if (m.dartDoc != null) {
- s.write(depth + '/// ');
- s.writeAll(m.dartDoc!.split('\n'), '\n' + depth + '/// ');
+ s.write('$depth/// ');
+ s.writeAll(m.dartDoc!.split('\n'), '\n$depth/// ');
s.write('\n');
}
if (!sameDartAndCType(m.type, w)) {
diff --git a/lib/src/code_generator/enum_class.dart b/lib/src/code_generator/enum_class.dart
index 4e8ec3a..081c864 100644
--- a/lib/src/code_generator/enum_class.dart
+++ b/lib/src/code_generator/enum_class.dart
@@ -61,11 +61,11 @@
for (final ec in enumConstants) {
final enumValueName = localUniqueNamer.makeUnique(ec.name);
if (ec.dartDoc != null) {
- s.write(depth + '/// ');
- s.writeAll(ec.dartDoc!.split('\n'), '\n' + depth + '/// ');
+ s.write('$depth/// ');
+ s.writeAll(ec.dartDoc!.split('\n'), '\n$depth/// ');
s.write('\n');
}
- s.write(depth + 'static const int $enumValueName = ${ec.value};\n');
+ s.write('${depth}static const int $enumValueName = ${ec.value};\n');
}
s.write('}\n\n');
diff --git a/lib/src/code_generator/objc_built_in_functions.dart b/lib/src/code_generator/objc_built_in_functions.dart
index e7f5bd5..ebb4b20 100644
--- a/lib/src/code_generator/objc_built_in_functions.dart
+++ b/lib/src/code_generator/objc_built_in_functions.dart
@@ -99,7 +99,7 @@
Func getMsgSendFunc(Type returnType, List<ObjCMethodParam> params) {
var key = returnType.cacheKey();
for (final p in params) {
- key += ' ' + p.type.cacheKey();
+ key += ' ${p.type.cacheKey()}';
}
return _msgSendFuncs[key] ??= Func(
name: '_objc_msgSend_${_msgSendFuncs.length}',
diff --git a/lib/src/code_generator/objc_interface.dart b/lib/src/code_generator/objc_interface.dart
index 8ca0b8e..2cf44af 100644
--- a/lib/src/code_generator/objc_interface.dart
+++ b/lib/src/code_generator/objc_interface.dart
@@ -81,7 +81,7 @@
(_getConvertedType(p.type, w, name) +
(p.isNullable ? "? " : " ") +
p.name)));
- return '(' + stringParams.join(", ") + ')';
+ return '(${stringParams.join(", ")})';
}
final s = StringBuffer();
@@ -364,7 +364,7 @@
Type type, Writer w, String enclosingClass, bool isNullableReturn) {
final result = _getConvertedType(type, w, enclosingClass);
if (isNullableReturn) {
- return result + "?";
+ return "$result?";
}
return result;
}
diff --git a/lib/src/config_provider/config.dart b/lib/src/config_provider/config.dart
index 9c094ed..6290bac 100644
--- a/lib/src/config_provider/config.dart
+++ b/lib/src/config_provider/config.dart
@@ -178,7 +178,7 @@
factory Config.fromYaml(YamlMap map,
{String? filename, PackageConfig? packageConfig}) {
final configspecs = Config._(filename, packageConfig);
- _logger.finest('Config Map: ' + map.toString());
+ _logger.finest('Config Map: $map');
final specs = configspecs._getSpecs();
@@ -213,15 +213,14 @@
/// Validates Yaml according to given specs.
bool _checkConfigs(YamlMap map, Map<List<String>, Specification> specs) {
- var _result = true;
+ var result = true;
for (final key in specs.keys) {
final spec = specs[key];
if (checkKeyInYaml(key, map)) {
- _result =
- _result && spec!.validator(key, getKeyValueFromYaml(key, map));
+ result = result && spec!.validator(key, getKeyValueFromYaml(key, map));
} else if (spec!.requirement == Requirement.yes) {
_logger.severe("Key '$key' is required.");
- _result = false;
+ result = false;
} else if (spec.requirement == Requirement.prefer) {
_logger.warning("Prefer adding Key '$key' to your config.");
}
@@ -229,7 +228,7 @@
// Warn about unknown keys.
warnUnknownKeys(specs.keys.toList(), map);
- return _result;
+ return result;
}
/// Extracts variables from Yaml according to given specs.
diff --git a/lib/src/config_provider/path_finder.dart b/lib/src/config_provider/path_finder.dart
index 3f6a597..715e1ac 100644
--- a/lib/src/config_provider/path_finder.dart
+++ b/lib/src/config_provider/path_finder.dart
@@ -20,7 +20,7 @@
'/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include';
if (Directory(systemHeaders).existsSync()) {
_logger.fine('Added $systemHeaders to compiler-opts.');
- includePaths.add('-I' + systemHeaders);
+ includePaths.add('-I$systemHeaders');
}
/// Find headers from XCode or LLVM installed via brew.
@@ -39,7 +39,7 @@
final path = p.join(searchPath, version, 'include');
if (Directory(path).existsSync()) {
_logger.fine('Added stdlib path: $path to compiler-opts.');
- includePaths.add('-I' + path);
+ includePaths.add('-I$path');
return includePaths;
}
}
@@ -51,7 +51,7 @@
'/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Headers/';
if (Directory(cmdLineToolHeaders).existsSync()) {
_logger.fine('Added stdlib path: $cmdLineToolHeaders to compiler-opts.');
- includePaths.add('-I' + cmdLineToolHeaders);
+ includePaths.add('-I$cmdLineToolHeaders');
return includePaths;
}
diff --git a/lib/src/config_provider/spec_utils.dart b/lib/src/config_provider/spec_utils.dart
index 8430c62..9b03ebb 100644
--- a/lib/src/config_provider/spec_utils.dart
+++ b/lib/src/config_provider/spec_utils.dart
@@ -82,13 +82,13 @@
void warnUnknownKeys(List<List<String>> allowedKeyList, YamlMap configKeyMap) {
final allowedKeyMap = <String, dynamic>{};
for (final specKeys in allowedKeyList) {
- var _item = allowedKeyMap;
+ var item = allowedKeyMap;
for (final specSubKey in specKeys) {
- _item.putIfAbsent(specSubKey, () => <String, dynamic>{});
- _item = _item[specSubKey] as Map<String, dynamic>;
+ item.putIfAbsent(specSubKey, () => <String, dynamic>{});
+ item = item[specSubKey] as Map<String, dynamic>;
}
// Add empty key to mark that any sub-keys of this key are allowed.
- _item[''] = <String, dynamic>{};
+ item[''] = <String, dynamic>{};
}
_warnUnknownKeysInMap(allowedKeyMap, configKeyMap, <dynamic>[]);
}
@@ -379,7 +379,7 @@
}
bool compilerOptsAutoValidator(List<String> name, dynamic value) {
- var _result = true;
+ var result = true;
if (!checkType<YamlMap>(name, value)) {
return false;
@@ -395,19 +395,19 @@
if (inckey == strings.includeCStdLib) {
if (!checkType<bool>(
[...name, oskey, inckey as String], value[oskey][inckey])) {
- _result = false;
+ result = false;
}
} else {
_logger.severe("Unknown key '$inckey' in '$name -> $oskey.");
- _result = false;
+ result = false;
}
}
} else {
_logger.severe("Unknown key '$oskey' in '$name'.");
- _result = false;
+ result = false;
}
}
- return _result;
+ return result;
}
Headers headersExtractor(dynamic yamlConfig, String? configFilename) {
@@ -814,32 +814,32 @@
}
bool declarationConfigValidator(List<String> name, dynamic value) {
- var _result = true;
+ var result = true;
if (value is YamlMap) {
for (final key in value.keys) {
if (key == strings.include || key == strings.exclude) {
if (!checkType<YamlList>([...name, key as String], value[key])) {
- _result = false;
+ result = false;
}
} else if (key == strings.rename) {
if (!checkType<YamlMap>([...name, key as String], value[key])) {
- _result = false;
+ result = false;
} else {
for (final subkey in (value[key] as YamlMap).keys) {
if (!checkType<String>(
[...name, key, subkey as String], value[key][subkey])) {
- _result = false;
+ result = false;
}
}
}
} else if (key == strings.memberRename) {
if (!checkType<YamlMap>([...name, key as String], value[key])) {
- _result = false;
+ result = false;
} else {
for (final declNameKey in (value[key] as YamlMap).keys) {
if (!checkType<YamlMap>([...name, key, declNameKey as String],
value[key][declNameKey])) {
- _result = false;
+ result = false;
} else {
for (final memberNameKey
in ((value[key] as YamlMap)[declNameKey] as YamlMap).keys) {
@@ -849,7 +849,7 @@
declNameKey,
memberNameKey as String,
], value[key][declNameKey][memberNameKey])) {
- _result = false;
+ result = false;
}
}
}
@@ -857,17 +857,17 @@
}
} else if (key == strings.symbolAddress) {
if (!checkType<YamlMap>([...name, key as String], value[key])) {
- _result = false;
+ result = false;
} else {
for (final subkey in (value[key] as YamlMap).keys) {
if (subkey == strings.include || subkey == strings.exclude) {
if (!checkType<YamlList>(
[...name, key, subkey as String], value[key][subkey])) {
- _result = false;
+ result = false;
}
} else {
_logger.severe("Unknown key '$subkey' in '$name -> $key'.");
- _result = false;
+ result = false;
}
}
}
@@ -875,59 +875,59 @@
}
} else {
_logger.severe("Expected value '$name' to be a Map.");
- _result = false;
+ result = false;
}
- return _result;
+ return result;
}
Includer exposeFunctionTypeExtractor(dynamic value) =>
_extractIncluderFromYaml(value);
bool exposeFunctionTypeValidator(List<String> name, dynamic value) {
- var _result = true;
+ var result = true;
if (!checkType<YamlMap>(name, value)) {
- _result = false;
+ result = false;
} else {
final mp = value as YamlMap;
for (final key in mp.keys) {
if (key == strings.include || key == strings.exclude) {
if (!checkType<YamlList>([...name, key as String], value[key])) {
- _result = false;
+ result = false;
}
} else {
_logger.severe("Unknown subkey '$key' in '$name'.");
- _result = false;
+ result = false;
}
}
}
- return _result;
+ return result;
}
Includer leafFunctionExtractor(dynamic value) =>
_extractIncluderFromYaml(value);
bool leafFunctionValidator(List<String> name, dynamic value) {
- var _result = true;
+ var result = true;
if (!checkType<YamlMap>(name, value)) {
- _result = false;
+ result = false;
} else {
final mp = value as YamlMap;
for (final key in mp.keys) {
if (key == strings.include || key == strings.exclude) {
if (!checkType<YamlList>([...name, key as String], value[key])) {
- _result = false;
+ result = false;
}
} else {
_logger.severe("Unknown subkey '$key' in '$name'.");
- _result = false;
+ result = false;
}
}
}
- return _result;
+ return result;
}
SupportedNativeType nativeSupportedType(int value, {bool signed = true}) {
@@ -1059,21 +1059,21 @@
}
bool structPackingOverrideValidator(List<String> name, dynamic value) {
- var _result = true;
+ var result = true;
if (!checkType<YamlMap>([...name], value)) {
- _result = false;
+ result = false;
} else {
for (final key in (value as YamlMap).keys) {
if (!(strings.packingValuesMap.keys.contains(value[key]))) {
_logger.severe(
"'$name -> $key' must be one of the following - ${strings.packingValuesMap.keys.toList()}");
- _result = false;
+ result = false;
}
}
}
- return _result;
+ return result;
}
FfiNativeConfig ffiNativeExtractor(dynamic yamlConfig) {
diff --git a/lib/src/header_parser/sub_parsers/objc_block_parser.dart b/lib/src/header_parser/sub_parsers/objc_block_parser.dart
index 83f8223..f7ac662 100644
--- a/lib/src/header_parser/sub_parsers/objc_block_parser.dart
+++ b/lib/src/header_parser/sub_parsers/objc_block_parser.dart
@@ -22,9 +22,9 @@
// Create a fake USR code for the block. This code is used to dedupe blocks
// with the same signature.
- var usr = 'objcBlock: ' + returnType.cacheKey();
+ var usr = 'objcBlock: ${returnType.cacheKey()}';
for (final type in argTypes) {
- usr += ' ' + type.cacheKey();
+ usr += ' ${type.cacheKey()}';
}
_logger.fine('++++ Adding ObjC block: '
diff --git a/lib/src/header_parser/type_extractor/extractor.dart b/lib/src/header_parser/type_extractor/extractor.dart
index 135265f..d6b87f2 100644
--- a/lib/src/header_parser/type_extractor/extractor.dart
+++ b/lib/src/header_parser/type_extractor/extractor.dart
@@ -296,7 +296,7 @@
// Used for function pointer arguments.
Type _extractFromFunctionProto(clang_types.CXType cxtype) {
- final _parameters = <Parameter>[];
+ final parameters = <Parameter>[];
final totalArgs = clang.clang_getNumArgTypes(cxtype);
for (var i = 0; i < totalArgs; i++) {
final t = clang.clang_getArgType(cxtype, i);
@@ -309,13 +309,13 @@
return UnimplementedType('Function parameter has an unsupported type.');
}
- _parameters.add(
+ parameters.add(
Parameter(name: '', type: pt),
);
}
return NativeFunc(FunctionType(
- parameters: _parameters,
+ parameters: parameters,
returnType: clang.clang_getResultType(cxtype).toCodeGenType(),
));
}
diff --git a/lib/src/header_parser/utils.dart b/lib/src/header_parser/utils.dart
index 355bf3a..0b4770f 100644
--- a/lib/src/header_parser/utils.dart
+++ b/lib/src/header_parser/utils.dart
@@ -47,7 +47,7 @@
clang_types
.CXDiagnosticDisplayOptions.CXDiagnostic_DisplayCategoryName,
);
- logger.log(logLevel, ' ' + cxstring.toStringAndDispose());
+ logger.log(logLevel, ' ${cxstring.toStringAndDispose()}');
clang.clang_disposeDiagnostic(diag);
}
}
diff --git a/lib/src/strings.dart b/lib/src/strings.dart
index 180c198..e0f2761 100644
--- a/lib/src/strings.dart
+++ b/lib/src/strings.dart
@@ -151,7 +151,7 @@
const usedConfig = "used-config";
const import = 'import';
-const defaultSymbolFileImportPrefix = '_imp';
+const defaultSymbolFileImportPrefix = 'imp';
// Sub keys of import.
const symbolFilesImport = 'symbol-files';
diff --git a/pubspec.yaml b/pubspec.yaml
index 015c592..96c6027 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -17,12 +17,12 @@
quiver: ^3.0.0
args: ^2.0.0
logging: ^1.0.0
- cli_util: ^0.3.0
+ cli_util: ^0.4.0
glob: ^2.0.0
file: ^6.0.0
package_config: ^2.1.0
yaml_edit: ^2.0.3
dev_dependencies:
- lints: ^1.0.1
+ lints: ^2.0.1
test: ^1.16.2
diff --git a/test/config_tests/packed_struct_override_test.dart b/test/config_tests/packed_struct_override_test.dart
index 9f9726d..cb0bf3c 100644
--- a/test/config_tests/packed_struct_override_test.dart
+++ b/test/config_tests/packed_struct_override_test.dart
@@ -26,15 +26,15 @@
''';
expect(
() => Config.fromYaml(
- yaml.loadYaml(baseYaml + "'.*': null") as yaml.YamlMap),
+ yaml.loadYaml("$baseYaml'.*': null") as yaml.YamlMap),
throwsA(TypeMatcher<FormatException>()));
expect(
() => Config.fromYaml(
- yaml.loadYaml(baseYaml + "'.*': 3") as yaml.YamlMap),
+ yaml.loadYaml("$baseYaml'.*': 3") as yaml.YamlMap),
throwsA(TypeMatcher<FormatException>()));
expect(
() => Config.fromYaml(
- yaml.loadYaml(baseYaml + "'.*': 32") as yaml.YamlMap),
+ yaml.loadYaml("$baseYaml'.*': 32") as yaml.YamlMap),
throwsA(TypeMatcher<FormatException>()));
});
test('Override values', () {