@@ -560,32 +560,32 @@ private String extractPackageName(String line) {
560560 public boolean IgnoredLine (String line ) {
561561 boolean result = false ;
562562 if (IgnorePatternDetector .containsIgnorePattern (line )) {
563- // if exhortignore or trustify-da-ignore is alone in a comment or is in a comment together
564- // with indirect or as a
565- // comment inside a
566- // comment ( e.g // indirect //exhort)
567- // then this line is to be checked if it's a comment after a package name.
568- if ( Pattern . matches ( ".+// \\ s*( exhortignore|trustify-da-ignore)" , line )
569- || Pattern . matches (
570- ".+// \\ s* indirect\\ s*; \\ s*(//)? \\ s*( exhortignore|trustify-da-ignore)" , line )) {
571- String trimmedRow = line . trim ();
572- // filter out lines where exhortignore or trustify-da-ignore has no meaning
573- if (! trimmedRow . startsWith ( "module " )
574- && ! trimmedRow . startsWith ( "go " )
575- && !trimmedRow .startsWith ("require ( " )
576- && !trimmedRow .startsWith ("require( " )
577- && !trimmedRow .startsWith ("exclude " )
578- && !trimmedRow .startsWith ("replace " )
579- && !trimmedRow .startsWith ("retract " )
580- && !trimmedRow .startsWith ("use " )
581- && !trimmedRow .contains (
582- "=>" )) { // only for lines that after trimming starts with "require " or starting
583- // with
584- // package name followd by one space, and then a semver version.
585- if ( trimmedRow . startsWith ( "require " )
586- || Pattern . matches (
587- "^[a-z.0-9/-]+ \\ s{1,2}[vV][0-9] \\ .[0-9]( \\ .[0-9]){0,2}.*" , trimmedRow )) {
588- result = true ;
563+ String trimmedRow = line . trim ();
564+ int firstComment = trimmedRow . indexOf ( "//" );
565+ if ( firstComment >= 0 ) {
566+ String comment = trimmedRow . substring ( firstComment + 2 ). trim ();
567+ // Match standalone ignore pattern (e.g. "// exhortignore") or
568+ // semicolon-separated with indirect (e.g. "// indirect; exhortignore",
569+ // "// indirect; // exhortignore").
570+ // Does NOT match "// indirect // exhortignore" (no semicolon) or
571+ // "// indirect exhortignore" (space-separated) — these are incorrect formats.
572+ if ( comment . matches ( "( exhortignore| trustify-da-ignore)" )
573+ || comment . matches ( "indirect \\ s*; \\ s*(//)? \\ s*(exhortignore|trustify-da-ignore)" )) {
574+ // filter out lines where exhortignore or trustify-da-ignore has no meaning
575+ if ( !trimmedRow .startsWith ("module " )
576+ && !trimmedRow .startsWith ("go " )
577+ && !trimmedRow .startsWith ("require ( " )
578+ && !trimmedRow .startsWith ("require( " )
579+ && !trimmedRow .startsWith ("exclude " )
580+ && !trimmedRow .startsWith ("replace " )
581+ && !trimmedRow .startsWith ( "retract " )
582+ && ! trimmedRow . startsWith ( "use " )
583+ && ! trimmedRow . contains ( "=>" )) {
584+ if ( trimmedRow . startsWith ( "require " )
585+ || Pattern . matches (
586+ "^[a-z.0-9/-]+ \\ s{1,2}[vV][0-9] \\ .[0-9]( \\ .[0-9]){0,2}.*" , trimmedRow )) {
587+ result = true ;
588+ }
589589 }
590590 }
591591 }
0 commit comments