stable

Clone or download

Read-only

refactor: Drop InvalidFieldChecker interface

part of story #10710 search on fields with duck typing No functional change. CI should be happy. Why? Now that all the validation rules are grouped by type of field, the goal is to remove another level of indirection: $parameters->getCheckerProvider()->getInvalidFieldChecker()->check(). Due to the way the Field Visitor works, we cannot pass parameters to it. This means we cannot pass the current Comparison to the check method directly in the "accept*" methods. This is why the CollectorParameters included a class that returns the checker, instead of just doing the check immediately. Hence the existence of the IProvideTheInvalidFieldCheckerForAComparison and InvalidFieldChecker interfaces. In order to work around this problem, we replace the Field Visitor by a match on field classname. It breaks again the "visitor" spirit, but also has advantages: - default branch of match expression should handle all new fields as "external" fields (this was not the case in the visitor which required adding a method) - we can pass different parameters to each branch. With the visitor, there are no parameters (hence the additional indirection) - it is more concise code - InvalidSearchableCollectorParameters no longer needs to depend on field "Checker" class. The FlatInvalidFieldChecker can be injected at a higher level. Change-Id: Id48bded6acd455b4fb37bd3631203bef005d1116

Modified Files

Name
M plugins/crosstracker/include/CrossTracker/REST/v1/CrossTrackerReportsResource.php +21 −18 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/Query/Advanced/InvalidSearchableCollectorParameters.php +4 −11 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/Query/Advanced/InvalidSearchableCollectorVisitor.php +2 −2 Go to diff View file
M plugins/crosstracker/include/CrossTracker/Report/Query/Advanced/InvalidTermCollectorVisitor.php +0 −3 Go to diff View file
R plugins/crosstracker/include/CrossTracker/Report/Query/Advanced/QueryValidation/Field/FieldUsageChecker.php Go to diff View file
M plugins/crosstracker/include/crosstrackerPlugin.php +21 −18 Go to diff View file
M plugins/crosstracker/tests/integration/CrossTracker/Tests/Report/ArtifactReportFactoryInstantiator.php +21 −18 Go to diff View file
M plugins/crosstracker/tests/unit/CrossTracker/Report/Query/Advanced/InvalidTermCollectorVisitorTest.php +21 −18 Go to diff View file
R plugins/crosstracker/tests/unit/CrossTracker/Report/Query/Advanced/QueryValidation/Field/FieldUsageCheckerTest.php Go to diff View file
M plugins/crosstracker/tests/unit/CrossTracker/Tests/Builders/InvalidSearchableCollectorParametersBuilder.php +2 −35 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/Date/DateFieldChecker.php +2 −4 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/File/FileFieldChecker.php +1 −2 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/FlatInvalidFieldChecker.php +33 −127 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/FloatFields/FloatFieldChecker.php +1 −2 Go to diff View file
D plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/IProvideTheInvalidFieldCheckerForAComparison.php +0 −31 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/Integer/IntegerFieldChecker.php +1 −2 Go to diff View file
D plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/InvalidFieldChecker.php +0 −28 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/ListFields/ArtifactSubmitterChecker.php +1 −2 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/ListFields/ListFieldChecker.php +2 −4 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidFields/Text/TextFieldChecker.php +1 −2 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidSearchableCollectorParameters.php +7 −47 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidSearchableCollectorVisitor.php +3 −3 Go to diff View file
M plugins/tracker/include/Tracker/Report/Query/Advanced/InvalidTermCollectorVisitor.php +0 −3 Go to diff View file
M plugins/tracker/include/Tracker/Report/Tracker_Report.class.php +16 −16 Go to diff View file
M plugins/tracker/tests/unit/Tracker/Report/Query/Advanced/InvalidTermCollectorVisitorTest.php +21 −17 Go to diff View file