Skip to content

Commit

Permalink
Analyze fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Carapacik committed Dec 4, 2024
1 parent db61860 commit df890f4
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ String _validateMethod(String className, List<UniversalType> types) {
bodyBuffer
..write('try {\n')
..write(
' if ($nullCheckCondition $typeName.length < ${staticName}MinItems) {\n')
' if ($nullCheckCondition $typeName.length < ${staticName}MinItems) {\n',
)
..write(' return false;\n')
..write(' }\n')
..write('} catch (e) {\n')
Expand All @@ -77,7 +78,8 @@ String _validateMethod(String className, List<UniversalType> types) {
bodyBuffer
..write('try {\n')
..write(
' if ($nullCheckCondition $typeName.length > ${staticName}MaxItems) {\n')
' if ($nullCheckCondition $typeName.length > ${staticName}MaxItems) {\n',
)
..write(' return false;\n')
..write(' }\n')
..write('} catch (e) {\n')
Expand All @@ -89,7 +91,8 @@ String _validateMethod(String className, List<UniversalType> types) {
bodyBuffer
..write('try {\n')
..write(
' if ($nullCheckCondition $typeName.length < ${staticName}MinLength) {\n')
' if ($nullCheckCondition $typeName.length < ${staticName}MinLength) {\n',
)
..write(' return false;\n')
..write(' }\n')
..write('} catch (e) {\n')
Expand All @@ -101,7 +104,8 @@ String _validateMethod(String className, List<UniversalType> types) {
bodyBuffer
..write('try {\n')
..write(
' if ($nullCheckCondition $typeName.length > ${staticName}MaxLength) {\n')
' if ($nullCheckCondition $typeName.length > ${staticName}MaxLength) {\n',
)
..write(' return false;\n')
..write(' }\n')
..write('} catch (e) {\n')
Expand All @@ -113,7 +117,8 @@ String _validateMethod(String className, List<UniversalType> types) {
bodyBuffer
..write('try {\n')
..write(
' if ($nullCheckCondition !RegExp(${staticName}Pattern).hasMatch($typeName)) {\n')
' if ($nullCheckCondition !RegExp(${staticName}Pattern).hasMatch($typeName)) {\n',
)
..write(' return false;\n')
..write(' }\n')
..write('} catch (e) {\n')
Expand All @@ -125,7 +130,8 @@ String _validateMethod(String className, List<UniversalType> types) {
bodyBuffer
..write('try {\n')
..write(
' if ($nullCheckCondition ${staticName}UniqueItems && $typeName.toSet().length != $typeName.length) {\n')
' if ($nullCheckCondition ${staticName}UniqueItems && $typeName.toSet().length != $typeName.length) {\n',
)
..write(' return false;\n')
..write(' }\n')
..write('} catch (e) {\n')
Expand Down Expand Up @@ -180,12 +186,14 @@ String? _validationString(UniversalType type) {

if (type.pattern != null) {
sb.write(
' static const String ${type.name}Pattern = r"${type.pattern}";\n');
' static const String ${type.name}Pattern = r"${type.pattern}";\n',
);
}

if (type.uniqueItems != null) {
sb.write(
' static const bool ${type.name}UniqueItems = ${type.uniqueItems};\n');
' static const bool ${type.name}UniqueItems = ${type.uniqueItems};\n',
);
}

return sb.isEmpty ? null : sb.toString();
Expand Down

0 comments on commit df890f4

Please sign in to comment.