@@ -635,6 +635,19 @@ module TestPostProcessing {
635635
636636 signature module InputSig< InlineExpectationsTestSig Input> {
637637 string getRelativeUrl ( Input:: Location location ) ;
638+
639+ /**
640+ * Holds if results at the given location should be ignored.
641+ *
642+ * This is useful when it is impossible to insert expectation comments, for example
643+ * inside Ruby here-docs.
644+ */
645+ bindingset [ filePath, startLine, startColumn, endLine, endColumn]
646+ default predicate ignoreResult (
647+ string filePath , int startLine , int startColumn , int endLine , int endColumn
648+ ) {
649+ none ( )
650+ }
638651 }
639652
640653 module Make< InlineExpectationsTestSig Input, InputSig< Input > Input2> {
@@ -744,7 +757,11 @@ module TestPostProcessing {
744757
745758 pragma [ nomagic]
746759 private predicate mainQueryResult ( int row , int column , TestLocation loc ) {
747- queryResults ( mainResultSet ( ) , row , column , loc .getRelativeUrl ( ) )
760+ queryResults ( mainResultSet ( ) , row , column , loc .getRelativeUrl ( ) ) and
761+ not exists ( string filePath , int startLine , int startColumn , int endLine , int endColumn |
762+ loc .hasLocationInfo ( filePath , startLine , startColumn , endLine , endColumn ) and
763+ Input2:: ignoreResult ( filePath , startLine , startColumn , endLine , endColumn )
764+ )
748765 }
749766
750767 /**
@@ -755,10 +772,14 @@ module TestPostProcessing {
755772 */
756773 private string getSourceTag ( int row ) {
757774 getQueryKind ( ) = "path-problem" and
758- exists ( TestLocation sourceLoc , TestLocation selectLoc |
759- mainQueryResult ( row , 0 , selectLoc ) and
775+ exists ( TestLocation sourceLoc |
760776 mainQueryResult ( row , 2 , sourceLoc ) and
761- if sameLineInfo ( selectLoc , sourceLoc ) then result = "Alert" else result = "Source"
777+ if
778+ exists ( TestLocation selectLoc |
779+ mainQueryResult ( row , 0 , selectLoc ) and sameLineInfo ( selectLoc , sourceLoc )
780+ )
781+ then result = "Alert"
782+ else result = "Source"
762783 )
763784 }
764785
@@ -770,10 +791,14 @@ module TestPostProcessing {
770791 */
771792 private string getSinkTag ( int row ) {
772793 getQueryKind ( ) = "path-problem" and
773- exists ( TestLocation sinkLoc , TestLocation selectLoc |
774- mainQueryResult ( row , 0 , selectLoc ) and
794+ exists ( TestLocation sinkLoc |
775795 mainQueryResult ( row , 4 , sinkLoc ) and
776- if sameLineInfo ( selectLoc , sinkLoc ) then result = "Alert" else result = "Sink"
796+ if
797+ exists ( TestLocation selectLoc |
798+ mainQueryResult ( row , 0 , selectLoc ) and sameLineInfo ( selectLoc , sinkLoc )
799+ )
800+ then result = "Alert"
801+ else result = "Sink"
777802 )
778803 }
779804
0 commit comments