Skip to content

Commit

Permalink
fix: analyzer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Tienisto committed Dec 7, 2024
1 parent 244e7b1 commit 81187d2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
4 changes: 3 additions & 1 deletion slang/lib/src/builder/generator/generate_translations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ void _generateClass(
if (!localeData.base ||
node.interface?.attributes
.any((attribute) => attribute.attributeName == key) ==
true) buffer.write('@override ');
true) {
buffer.write('@override ');
}

// even if this attribute exist, it has to satisfy the same signature as
// specified in the interface
Expand Down
35 changes: 14 additions & 21 deletions slang/lib/src/builder/utils/string_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,15 @@ extension StringExtensions on String {
/// transforms the string to the specified case
/// if case is null, then no transformation will be applied
String toCase(CaseStyle? style) {
switch (style) {
case CaseStyle.camel:
return getWords()
.mapIndexed((index, word) =>
index == 0 ? word.toLowerCase() : word.capitalize())
.join('');
case CaseStyle.pascal:
return getWords().map((word) => word.capitalize()).join('');
case CaseStyle.snake:
return getWords().map((word) => word.toLowerCase()).join('_');
case null:
return this;
default:
print('Unknown case: $style');
return this;
}
return switch (style) {
CaseStyle.camel => getWords()
.mapIndexed((index, word) =>
index == 0 ? word.toLowerCase() : word.capitalize())
.join(''),
CaseStyle.pascal => getWords().map((word) => word.capitalize()).join(''),
CaseStyle.snake => getWords().map((word) => word.toLowerCase()).join('_'),
null => this,
};
}

/// de-DE will be interpreted as [de,DE]
Expand All @@ -42,9 +35,9 @@ extension StringExtensions on String {
/// assume that words are separated by special characters or by camel case
List<String> getWords() {
final input = this;
final StringBuffer buffer = StringBuffer();
final List<String> words = [];
final bool isAllCaps = input.toUpperCase() == input;
final buffer = StringBuffer();
final words = <String>[];
final isAllCaps = input.toUpperCase() == input;

for (int i = 0; i < input.length; i++) {
final String currChar = input[i];
Expand All @@ -70,5 +63,5 @@ extension StringExtensions on String {
}
}

final RegExp _upperAlphaRegex = RegExp(r'[A-Z]');
final Set<String> _symbolSet = {' ', '.', '_', '-', '/', '\\'};
final _upperAlphaRegex = RegExp(r'[A-Z]');
final _symbolSet = <String>{' ', '.', '_', '-', '/', '\\'};
2 changes: 1 addition & 1 deletion slang/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ dependencies:

dev_dependencies:
expect_error: ^1.0.7
lints: ^2.0.0
lints: any
test: ^1.21.0
1 change: 1 addition & 0 deletions slang/test/integration/main/compilation_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@Skip('not updated for multiple files')
library;

import 'package:expect_error/expect_error.dart';
import 'package:test/test.dart';
Expand Down
2 changes: 1 addition & 1 deletion slang_build_runner/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ dependencies:
slang: '>=4.3.0 <4.4.0'

dev_dependencies:
lints: ^2.0.0
lints: any

0 comments on commit 81187d2

Please sign in to comment.