diff --git a/lib/src/generators/logging/logger_class_content.dart b/lib/src/generators/logging/logger_class_content.dart index fdca4dd..e9e60a5 100644 --- a/lib/src/generators/logging/logger_class_content.dart +++ b/lib/src/generators/logging/logger_class_content.dart @@ -19,14 +19,14 @@ class SimpleLogPrinter extends LogPrinter { final String className; final bool printCallingFunctionName; final bool printCallStack; - final List exludeLogsFromClasses; + final List excludeLogsFromClasses; final String? showOnlyClass; SimpleLogPrinter( this.className, { this.printCallingFunctionName = true, this.printCallStack = false, - this.exludeLogsFromClasses = const [], + this.excludeLogsFromClasses = const [], this.showOnlyClass, }); @@ -46,7 +46,7 @@ class SimpleLogPrinter extends LogPrinter { var output = '\$emoji \$className\$methodNameSection - \${event.message}\${event.error != null ? '\\nERROR: \${event.error}\\n' : ''}\${printCallStack ? '\\nSTACKTRACE:\\n\$stackLog' : ''}'; - if (exludeLogsFromClasses.any( + if (excludeLogsFromClasses.any( (excludeClass) => className == excludeClass, ) || (showOnlyClass != null && className != showOnlyClass)) { @@ -98,7 +98,7 @@ class SimpleLogPrinter extends LogPrinter { .toList(); } - /// When the faulty word exists in the begging this method will not be very usefull + /// When the faulty word exists in the begging this method will not be very useful String _findMostMatchedTrace(List stackTraces, List keyWords) { String match = stackTraces.firstWhere( (trace) => _doesTraceContainsAllKeywords(trace, keyWords), @@ -148,12 +148,13 @@ List? _formatStackTrace(StackTrace stackTrace, int methodCount) { '''; -const String loggerClassNameAndOutputs = ''' +const String loggerClassNameAndOutputs = + ''' Logger $logHelperNameKey( String className, { bool printCallingFunctionName = true, bool printCallstack = false, - List exludeLogsFromClasses = const [], + List excludeLogsFromClasses = const [], String? showOnlyClass, }) { return Logger( @@ -162,7 +163,7 @@ Logger $logHelperNameKey( printCallingFunctionName: printCallingFunctionName, printCallStack: printCallstack, showOnlyClass: showOnlyClass, - exludeLogsFromClasses: exludeLogsFromClasses, + excludeLogsFromClasses: excludeLogsFromClasses, ), output: MultiOutput([ $disableConsoleOutputInRelease diff --git a/test/helpers/ast/logger_ast_validators.dart b/test/helpers/ast/logger_ast_validators.dart index 253d305..7875f33 100644 --- a/test/helpers/ast/logger_ast_validators.dart +++ b/test/helpers/ast/logger_ast_validators.dart @@ -25,12 +25,12 @@ import 'ast_helper.dart'; /// /// // Validate specific components /// LoggerClassGeneratorAstValidator.validateLoggerImports( -/// generatedCode, +/// generatedCode, /// expectedImports /// ); /// LoggerComponentAstValidator.validateSimpleLogPrinter(generatedCode); /// LoggerComponentAstValidator.validateLoggerFactory( -/// generatedCode, +/// generatedCode, /// expectedFunctionName /// ); /// ``` @@ -69,16 +69,16 @@ class LoggerClassGeneratorAstValidator { // Validate required imports validateLoggerImports(generatedCode, expectedConfig.imports); - + // Validate SimpleLogPrinter class LoggerComponentAstValidator.validateSimpleLogPrinter(generatedCode); - + // Validate stack trace utility functions LoggerComponentAstValidator.validateStackTraceUtilities(generatedCode); - + // Validate logger factory function LoggerComponentAstValidator.validateLoggerFactory( - generatedCode, + generatedCode, expectedConfig.logHelperName, expectedConfig.loggerOutputs, expectedConfig.disableReleaseConsoleOutput, @@ -88,19 +88,31 @@ class LoggerClassGeneratorAstValidator { /// Validates that required imports are present. /// /// Ensures Flutter foundation, logger package, and custom imports exist. - static void validateLoggerImports(String generatedCode, Set expectedImports) { + static void validateLoggerImports( + String generatedCode, + Set expectedImports, + ) { final unit = AstHelper.parseCode(generatedCode); - + // Required framework imports - expect(AstHelper.hasImport(unit, 'package:flutter/foundation.dart'), - isTrue, reason: 'Should import Flutter foundation'); - expect(AstHelper.hasImport(unit, 'package:logger/logger.dart'), - isTrue, reason: 'Should import logger package'); - + expect( + AstHelper.hasImport(unit, 'package:flutter/foundation.dart'), + isTrue, + reason: 'Should import Flutter foundation', + ); + expect( + AstHelper.hasImport(unit, 'package:logger/logger.dart'), + isTrue, + reason: 'Should import logger package', + ); + // Custom imports from config for (final importPath in expectedImports) { - expect(AstHelper.hasImport(unit, importPath), - isTrue, reason: 'Should import $importPath'); + expect( + AstHelper.hasImport(unit, importPath), + isTrue, + reason: 'Should import $importPath', + ); } } @@ -109,12 +121,21 @@ class LoggerClassGeneratorAstValidator { /// Checks that proper ignore directives are present. static void validateIgnoreComments(String generatedCode) { // Check for ignore comments at the top of the file - expect(generatedCode, contains('ignore_for_file'), - reason: 'Should contain ignore_for_file directive'); - expect(generatedCode, contains('avoid_print'), - reason: 'Should ignore avoid_print linting rule'); - expect(generatedCode, contains('depend_on_referenced_packages'), - reason: 'Should ignore depend_on_referenced_packages linting rule'); + expect( + generatedCode, + contains('ignore_for_file'), + reason: 'Should contain ignore_for_file directive', + ); + expect( + generatedCode, + contains('avoid_print'), + reason: 'Should ignore avoid_print linting rule', + ); + expect( + generatedCode, + contains('depend_on_referenced_packages'), + reason: 'Should ignore depend_on_referenced_packages linting rule', + ); } } @@ -128,27 +149,33 @@ class LoggerComponentAstValidator { /// Checks class declaration, constructor, fields, and log method. static void validateSimpleLogPrinter(String generatedCode) { final unit = AstHelper.parseCode(generatedCode); - + // Find SimpleLogPrinter class final printerClass = AstHelper.findClass(unit, 'SimpleLogPrinter'); - expect(printerClass, isNotNull, - reason: 'Should contain SimpleLogPrinter class'); - + expect( + printerClass, + isNotNull, + reason: 'Should contain SimpleLogPrinter class', + ); + if (printerClass != null) { // Should extend LogPrinter final extendsClause = printerClass.extendsClause; - expect(extendsClause?.superclass.name2.lexeme, equals('LogPrinter'), - reason: 'SimpleLogPrinter should extend LogPrinter'); - + expect( + extendsClause?.superclass.name2.lexeme, + equals('LogPrinter'), + reason: 'SimpleLogPrinter should extend LogPrinter', + ); + // Validate required fields _validatePrinterFields(printerClass); - + // Validate constructor _validatePrinterConstructor(printerClass); - + // Validate log method _validateLogMethod(printerClass); - + // Validate helper methods _validatePrinterHelperMethods(printerClass); } @@ -159,35 +186,51 @@ class LoggerComponentAstValidator { /// Checks for global utility functions and variables. static void validateStackTraceUtilities(String generatedCode) { final unit = AstHelper.parseCode(generatedCode); - + // Should have stackTraceRegex variable final stackTraceRegex = _findTopLevelVariable(unit, 'stackTraceRegex'); - expect(stackTraceRegex, isNotNull, - reason: 'Should have stackTraceRegex variable'); - + expect( + stackTraceRegex, + isNotNull, + reason: 'Should have stackTraceRegex variable', + ); + if (stackTraceRegex != null) { // Should contain RegExp in the initializer final firstVariable = stackTraceRegex.variables.first; final initializer = firstVariable.initializer?.toString() ?? ''; - expect(initializer, contains('RegExp'), - reason: 'stackTraceRegex should be initialized with RegExp'); + expect( + initializer, + contains('RegExp'), + reason: 'stackTraceRegex should be initialized with RegExp', + ); } - + // Should have _formatStackTrace function final formatFunction = _findTopLevelFunction(unit, '_formatStackTrace'); - expect(formatFunction, isNotNull, - reason: 'Should have _formatStackTrace function'); - + expect( + formatFunction, + isNotNull, + reason: 'Should have _formatStackTrace function', + ); + if (formatFunction != null) { // Should return List? final returnType = formatFunction.returnType?.toString(); - expect(returnType, anyOf(contains('List'), contains('String')), - reason: '_formatStackTrace should return List?'); - + expect( + returnType, + anyOf(contains('List'), contains('String')), + reason: '_formatStackTrace should return List?', + ); + // Should have StackTrace and int parameters - final parameters = formatFunction.functionExpression.parameters?.parameters ?? []; - expect(parameters.length, equals(2), - reason: '_formatStackTrace should have 2 parameters'); + final parameters = + formatFunction.functionExpression.parameters?.parameters ?? []; + expect( + parameters.length, + equals(2), + reason: '_formatStackTrace should have 2 parameters', + ); } } @@ -195,29 +238,39 @@ class LoggerComponentAstValidator { /// /// Checks function signature, parameters, and output configuration. static void validateLoggerFactory( - String generatedCode, + String generatedCode, String expectedFunctionName, List expectedOutputs, bool? disableReleaseConsoleOutput, ) { final unit = AstHelper.parseCode(generatedCode); - + // Find the logger factory function final factoryFunction = _findTopLevelFunction(unit, expectedFunctionName); - expect(factoryFunction, isNotNull, - reason: 'Should have $expectedFunctionName factory function'); - + expect( + factoryFunction, + isNotNull, + reason: 'Should have $expectedFunctionName factory function', + ); + if (factoryFunction != null) { // Should return Logger final returnType = factoryFunction.returnType?.toString(); - expect(returnType, contains('Logger'), - reason: '$expectedFunctionName should return Logger'); - + expect( + returnType, + contains('Logger'), + reason: '$expectedFunctionName should return Logger', + ); + // Validate function parameters _validateFactoryParameters(factoryFunction); - + // Validate function body contains expected outputs - _validateFactoryOutputs(factoryFunction, expectedOutputs, disableReleaseConsoleOutput); + _validateFactoryOutputs( + factoryFunction, + expectedOutputs, + disableReleaseConsoleOutput, + ); } } @@ -227,138 +280,201 @@ class LoggerComponentAstValidator { static void _validatePrinterFields(ClassDeclaration printerClass) { final expectedFields = [ 'className', - 'printCallingFunctionName', + 'printCallingFunctionName', 'printCallStack', - 'exludeLogsFromClasses', + 'excludeLogsFromClasses', 'showOnlyClass', 'printer', ]; - + for (final fieldName in expectedFields) { final field = AstHelper.findField(printerClass, fieldName); - expect(field, isNotNull, - reason: 'SimpleLogPrinter should have $fieldName field'); - + expect( + field, + isNotNull, + reason: 'SimpleLogPrinter should have $fieldName field', + ); + if (field != null && fieldName != 'printer') { // Most fields should be final - expect(AstHelper.isFieldFinal(field), isTrue, - reason: '$fieldName field should be final'); + expect( + AstHelper.isFieldFinal(field), + isTrue, + reason: '$fieldName field should be final', + ); } } } /// Validates SimpleLogPrinter constructor. static void _validatePrinterConstructor(ClassDeclaration printerClass) { - final constructor = AstHelper.findConstructor(printerClass, 'SimpleLogPrinter'); - expect(constructor, isNotNull, - reason: 'SimpleLogPrinter should have constructor'); - + final constructor = AstHelper.findConstructor( + printerClass, + 'SimpleLogPrinter', + ); + expect( + constructor, + isNotNull, + reason: 'SimpleLogPrinter should have constructor', + ); + if (constructor != null) { // Should have className as required parameter final parameters = constructor.parameters.parameters; - expect(parameters, isNotEmpty, - reason: 'Constructor should have parameters'); - + expect( + parameters, + isNotEmpty, + reason: 'Constructor should have parameters', + ); + // First parameter should be className final firstParam = parameters.first; - expect(firstParam.toString(), contains('className'), - reason: 'First parameter should be className'); + expect( + firstParam.toString(), + contains('className'), + reason: 'First parameter should be className', + ); } } /// Validates log method in SimpleLogPrinter. static void _validateLogMethod(ClassDeclaration printerClass) { final logMethod = AstHelper.findMethod(printerClass, 'log'); - expect(logMethod, isNotNull, - reason: 'SimpleLogPrinter should have log method'); - + expect( + logMethod, + isNotNull, + reason: 'SimpleLogPrinter should have log method', + ); + if (logMethod != null) { // Should have override annotation - expect(AstHelper.hasOverrideAnnotation(logMethod), isTrue, - reason: 'log method should have @override annotation'); - + expect( + AstHelper.hasOverrideAnnotation(logMethod), + isTrue, + reason: 'log method should have @override annotation', + ); + // Should return List final returnType = AstHelper.getMethodReturnType(logMethod); - expect(returnType, anyOf(contains('List'), contains('String')), - reason: 'log method should return List'); + expect( + returnType, + anyOf(contains('List'), contains('String')), + reason: 'log method should return List', + ); } } /// Validates SimpleLogPrinter helper methods. static void _validatePrinterHelperMethods(ClassDeclaration printerClass) { - final helperMethods = ['_getMethodName', '_splitClassNameWords', - '_findMostMatchedTrace', '_doesTraceContainsAllKeywords']; - + final helperMethods = [ + '_getMethodName', + '_splitClassNameWords', + '_findMostMatchedTrace', + '_doesTraceContainsAllKeywords', + ]; + for (final methodName in helperMethods) { final method = AstHelper.findMethod(printerClass, methodName); - expect(method, isNotNull, - reason: 'SimpleLogPrinter should have $methodName method'); + expect( + method, + isNotNull, + reason: 'SimpleLogPrinter should have $methodName method', + ); } } /// Validates factory function parameters. static void _validateFactoryParameters(FunctionDeclaration factoryFunction) { - final parameters = factoryFunction.functionExpression.parameters?.parameters ?? []; + final parameters = + factoryFunction.functionExpression.parameters?.parameters ?? []; final expectedParams = [ 'className', 'printCallingFunctionName', - 'printCallstack', - 'exludeLogsFromClasses', - 'showOnlyClass' + 'printCallstack', + 'excludeLogsFromClasses', + 'showOnlyClass', ]; - + // Should have at least the required parameters - expect(parameters.length, greaterThanOrEqualTo(1), - reason: 'Factory function should have parameters'); - + expect( + parameters.length, + greaterThanOrEqualTo(1), + reason: 'Factory function should have parameters', + ); + // Check parameter names are present in function signature final functionSignature = factoryFunction.toString(); for (final paramName in expectedParams) { - expect(functionSignature, contains(paramName), - reason: 'Factory function should have $paramName parameter'); + expect( + functionSignature, + contains(paramName), + reason: 'Factory function should have $paramName parameter', + ); } } /// Validates factory function output configuration. static void _validateFactoryOutputs( - FunctionDeclaration factoryFunction, + FunctionDeclaration factoryFunction, List expectedOutputs, bool? disableReleaseConsoleOutput, ) { final functionBody = factoryFunction.toString(); - + // Should contain MultiOutput - expect(functionBody, contains('MultiOutput'), - reason: 'Factory function should use MultiOutput'); - + expect( + functionBody, + contains('MultiOutput'), + reason: 'Factory function should use MultiOutput', + ); + // Should contain Logger instantiation - expect(functionBody, contains('Logger('), - reason: 'Factory function should instantiate Logger'); - + expect( + functionBody, + contains('Logger('), + reason: 'Factory function should instantiate Logger', + ); + // Should contain SimpleLogPrinter - expect(functionBody, contains('SimpleLogPrinter'), - reason: 'Factory function should use SimpleLogPrinter'); - + expect( + functionBody, + contains('SimpleLogPrinter'), + reason: 'Factory function should use SimpleLogPrinter', + ); + // Check console output conditional logic if (disableReleaseConsoleOutput == false) { - expect(functionBody, contains('ConsoleOutput()'), - reason: 'Should always include ConsoleOutput when not disabled'); + expect( + functionBody, + contains('ConsoleOutput()'), + reason: 'Should always include ConsoleOutput when not disabled', + ); } else { - expect(functionBody, contains('kReleaseMode'), - reason: 'Should have conditional compilation logic'); + expect( + functionBody, + contains('kReleaseMode'), + reason: 'Should have conditional compilation logic', + ); } - + // Check expected outputs are referenced for (final output in expectedOutputs) { - expect(functionBody, contains(output), - reason: 'Should reference output $output'); + expect( + functionBody, + contains(output), + reason: 'Should reference output $output', + ); } } /// Finds a top-level variable by name. - static VariableDeclarationList? _findTopLevelVariable(CompilationUnit unit, String name) { - final variables = unit.declarations.whereType(); - + static VariableDeclarationList? _findTopLevelVariable( + CompilationUnit unit, + String name, + ) { + final variables = unit.declarations + .whereType(); + for (final varDecl in variables) { for (final variable in varDecl.variables.variables) { if (variable.name.lexeme == name) { @@ -370,8 +486,11 @@ class LoggerComponentAstValidator { } /// Finds a top-level function by name. - static FunctionDeclaration? _findTopLevelFunction(CompilationUnit unit, String name) { + static FunctionDeclaration? _findTopLevelFunction( + CompilationUnit unit, + String name, + ) { final functions = unit.declarations.whereType(); return functions.where((f) => f.name.lexeme == name).firstOrNull; } -} \ No newline at end of file +} diff --git a/test/helpers/test_constants/logger_constants.dart b/test/helpers/test_constants/logger_constants.dart index a573169..cfd0c19 100644 --- a/test/helpers/test_constants/logger_constants.dart +++ b/test/helpers/test_constants/logger_constants.dart @@ -17,14 +17,14 @@ class SimpleLogPrinter extends LogPrinter { final String className; final bool printCallingFunctionName; final bool printCallStack; - final List exludeLogsFromClasses; + final List excludeLogsFromClasses; final String? showOnlyClass; SimpleLogPrinter( this.className, { this.printCallingFunctionName = true, this.printCallStack = false, - this.exludeLogsFromClasses = const [], + this.excludeLogsFromClasses = const [], this.showOnlyClass, }); @@ -44,7 +44,7 @@ class SimpleLogPrinter extends LogPrinter { var output = '\$emoji \$className\$methodNameSection - \${event.message}\${event.error != null ? '\\nERROR: \${event.error}\\n' : ''}\${printCallStack ? '\\nSTACKTRACE:\\n\$stackLog' : ''}'; - if (exludeLogsFromClasses.any( + if (excludeLogsFromClasses.any( (excludeClass) => className == excludeClass, ) || (showOnlyClass != null && className != showOnlyClass)) { @@ -96,7 +96,7 @@ class SimpleLogPrinter extends LogPrinter { .toList(); } - /// When the faulty word exists in the begging this method will not be very usefull + /// When the faulty word exists in the begging this method will not be very useful String _findMostMatchedTrace(List stackTraces, List keyWords) { String match = stackTraces.firstWhere( (trace) => _doesTraceContainsAllKeywords(trace, keyWords), @@ -148,7 +148,7 @@ Logger ebraLogger( String className, { bool printCallingFunctionName = true, bool printCallstack = false, - List exludeLogsFromClasses = const [], + List excludeLogsFromClasses = const [], String? showOnlyClass, }) { return Logger( @@ -157,7 +157,7 @@ Logger ebraLogger( printCallingFunctionName: printCallingFunctionName, printCallStack: printCallstack, showOnlyClass: showOnlyClass, - exludeLogsFromClasses: exludeLogsFromClasses, + excludeLogsFromClasses: excludeLogsFromClasses, ), output: MultiOutput([ if(!kReleaseMode) @@ -186,14 +186,14 @@ class SimpleLogPrinter extends LogPrinter { final String className; final bool printCallingFunctionName; final bool printCallStack; - final List exludeLogsFromClasses; + final List excludeLogsFromClasses; final String? showOnlyClass; SimpleLogPrinter( this.className, { this.printCallingFunctionName = true, this.printCallStack = false, - this.exludeLogsFromClasses = const [], + this.excludeLogsFromClasses = const [], this.showOnlyClass, }); @@ -213,7 +213,7 @@ class SimpleLogPrinter extends LogPrinter { var output = '\$emoji \$className\$methodNameSection - \${event.message}\${event.error != null ? '\\nERROR: \${event.error}\\n' : ''}\${printCallStack ? '\\nSTACKTRACE:\\n\$stackLog' : ''}'; - if (exludeLogsFromClasses.any( + if (excludeLogsFromClasses.any( (excludeClass) => className == excludeClass, ) || (showOnlyClass != null && className != showOnlyClass)) { @@ -265,7 +265,7 @@ class SimpleLogPrinter extends LogPrinter { .toList(); } - /// When the faulty word exists in the begging this method will not be very usefull + /// When the faulty word exists in the begging this method will not be very useful String _findMostMatchedTrace(List stackTraces, List keyWords) { String match = stackTraces.firstWhere( (trace) => _doesTraceContainsAllKeywords(trace, keyWords), @@ -317,7 +317,7 @@ Logger ebraLogger( String className, { bool printCallingFunctionName = true, bool printCallstack = false, - List exludeLogsFromClasses = const [], + List excludeLogsFromClasses = const [], String? showOnlyClass, }) { return Logger( @@ -326,7 +326,7 @@ Logger ebraLogger( printCallingFunctionName: printCallingFunctionName, printCallStack: printCallstack, showOnlyClass: showOnlyClass, - exludeLogsFromClasses: exludeLogsFromClasses, + excludeLogsFromClasses: excludeLogsFromClasses, ), output: MultiOutput([ @@ -341,12 +341,13 @@ const String kMultiLoggerImports = 'MultiLoggerImport'; const String kMultipleLoggerOutput = 'MultiLoggerList'; const String kDisableConsoleOutputInRelease = 'MultiLoggerList'; -const String kloggerClassNameAndOutputs = ''' +const String kloggerClassNameAndOutputs = + ''' Logger $kLogHelperNameKey( String className, { bool printCallingFunctionName = true, bool printCallstack = false, - List exludeLogsFromClasses = const [], + List excludeLogsFromClasses = const [], String? showOnlyClass, }) { return Logger( @@ -355,7 +356,7 @@ Logger $kLogHelperNameKey( printCallingFunctionName: printCallingFunctionName, printCallStack: printCallstack, showOnlyClass: showOnlyClass, - exludeLogsFromClasses: exludeLogsFromClasses, + excludeLogsFromClasses: excludeLogsFromClasses, ), output: MultipleLoggerOutput([ $kDisableConsoleOutputInRelease @@ -370,7 +371,7 @@ Logger ebraLogger( String className, { bool printCallingFunctionName = true, bool printCallstack = false, - List exludeLogsFromClasses = const [], + List excludeLogsFromClasses = const [], String? showOnlyClass, }) { return Logger( @@ -379,7 +380,7 @@ Logger ebraLogger( printCallingFunctionName: printCallingFunctionName, printCallStack: printCallstack, showOnlyClass: showOnlyClass, - exludeLogsFromClasses: exludeLogsFromClasses, + excludeLogsFromClasses: excludeLogsFromClasses, ), output: MultipleLoggerOutput([ @@ -409,7 +410,7 @@ Logger getLogger( String className, { bool printCallingFunctionName = true, bool printCallstack = false, - List exludeLogsFromClasses = const [], + List excludeLogsFromClasses = const [], String? showOnlyClass, }) { return Logger( @@ -418,7 +419,7 @@ Logger getLogger( printCallingFunctionName: printCallingFunctionName, printCallStack: printCallstack, showOnlyClass: showOnlyClass, - exludeLogsFromClasses: exludeLogsFromClasses, + excludeLogsFromClasses: excludeLogsFromClasses, ), output: MultiOutput([ if(!kReleaseMode) diff --git a/test/logging/web_support_test.dart b/test/logging/web_support_test.dart index eeb10a0..c268718 100644 --- a/test/logging/web_support_test.dart +++ b/test/logging/web_support_test.dart @@ -7,14 +7,17 @@ List _splitClassNameWords(String className) { .toList(); } -/// When the faulty word exists in the begging this method will not be very usefull +/// When the faulty word exists in the begging this method will not be very useful String _findMostMatchedTrace(List stackTraces, List keyWords) { String match = stackTraces.firstWhere( - (trace) => _doesTraceContainsAllKeywords(trace, keyWords), - orElse: () => ''); + (trace) => _doesTraceContainsAllKeywords(trace, keyWords), + orElse: () => '', + ); if (match.isEmpty) { match = _findMostMatchedTrace( - stackTraces, keyWords.sublist(0, keyWords.length - 1)); + stackTraces, + keyWords.sublist(0, keyWords.length - 1), + ); } return match; } @@ -54,47 +57,63 @@ void main() { ]; group('_splitClassNameWords -', () { test( - 'When class name is UserService, Should return two words [user, service]', - () { - expect(_splitClassNameWords('UserService'), ['user', 'service']); - }); + 'When class name is UserService, Should return two words [user, service]', + () { + expect(_splitClassNameWords('UserService'), ['user', 'service']); + }, + ); group('_doesTraceContainsAllKeywords -', () { test( - 'When call on a trace, Should return true if it contains all the words and false otherwise ', - () { - const trace = - "packages/intake/services/user_service.dart 26:9 syncUserAccount"; + 'When call on a trace, Should return true if it contains all the words and false otherwise ', + () { + const trace = + "packages/intake/services/user_service.dart 26:9 syncUserAccount"; - expect(_doesTraceContainsAllKeywords(trace, ['user', 'service']), - isTrue); + expect( + _doesTraceContainsAllKeywords(trace, ['user', 'service']), + isTrue, + ); - expect(_doesTraceContainsAllKeywords(trace, ['user', 'greate']), - isFalse); - }); + expect( + _doesTraceContainsAllKeywords(trace, ['user', 'greate']), + isFalse, + ); + }, + ); }); group('_findMostMatchedTrace -', () { test( - 'When call on a list of traces, Should return the first most matched trace with the provided keywords', - () { - final firstMostMatchedTrace = _findMostMatchedTrace( - exampleStackTraceOfWebAppLog, ['user', 'service']); + 'When call on a list of traces, Should return the first most matched trace with the provided keywords', + () { + final firstMostMatchedTrace = _findMostMatchedTrace( + exampleStackTraceOfWebAppLog, + ['user', 'service'], + ); - expect(firstMostMatchedTrace, exampleStackTraceOfWebAppLog[4]); - expect(firstMostMatchedTrace, example2StackTraceOfWebAppLog[1]); - }); + expect(firstMostMatchedTrace, exampleStackTraceOfWebAppLog[4]); + expect(firstMostMatchedTrace, example2StackTraceOfWebAppLog[1]); + }, + ); test( - 'When call on a list of traces and don\'t find all the keywords, Should remove a keyword from the list and try again', - () { - final firstMostMatchedTrace = _findMostMatchedTrace( - exampleStackTraceOfWebAppLog, ['user', 'service', 'office']); + 'When call on a list of traces and don\'t find all the keywords, Should remove a keyword from the list and try again', + () { + final firstMostMatchedTrace = _findMostMatchedTrace( + exampleStackTraceOfWebAppLog, + ['user', 'service', 'office'], + ); - expect(firstMostMatchedTrace, exampleStackTraceOfWebAppLog[4]); - }); + expect(firstMostMatchedTrace, exampleStackTraceOfWebAppLog[4]); + }, + ); test('Given a stacktrace from web log, Should return method name', () { expect( - _findMostMatchedTrace(exampleStackTraceOfWebAppLog, - ['user', 'service', 'office']).split(' ').last, - 'syncUserAccount'); + _findMostMatchedTrace(exampleStackTraceOfWebAppLog, [ + 'user', + 'service', + 'office', + ]).split(' ').last, + 'syncUserAccount', + ); }); }); });