@@ -561,20 +561,13 @@ struct GccPostProcessor::Private {
561
561
const LangDetector langDetector;
562
562
563
563
void transGccAnal (Defect *pDef) const ;
564
- void transGccSuffix (Defect *pDef) const ;
564
+ void transSuffixGeneric (Defect *pDef, const std::string, const RE & ) const ;
565
565
void transShellCheckId (Defect *pDef) const ;
566
566
567
- const RE reGccAnalCoreEvt =
568
- RE (" ^(.*) (\\ [-Wanalyzer-[^ \\ ]]+\\ ])$" );
569
-
570
- const RE reGccAnalCwe =
571
- RE (" ^(.*) \\ [CWE-([0-9]+)\\ ]$" );
572
-
573
- const RE reGccWarningEvt =
574
- RE (" ^(.*) (\\ [-W[^ \\ ]]+\\ ])$" );
575
-
576
- const RE reShellCheckId =
577
- RE (" (^.*) (\\ [SC([0-9]+)\\ ])$" );
567
+ const RE reGccAnalCoreEvt = RE(" ^(.*) (\\ [-Wanalyzer-[^ \\ ]]+\\ ])$" );
568
+ const RE reGccAnalCwe = RE(" ^(.*) \\ [CWE-([0-9]+)\\ ]$" );
569
+ const RE reGccWarningEvt = RE(" ^(.*) (\\ [-W[^ \\ ]]+\\ ])$" );
570
+ const RE reShellCheckId = RE(" (^.*) (\\ [SC([0-9]+)\\ ])$" );
578
571
};
579
572
580
573
GccPostProcessor::GccPostProcessor ():
@@ -613,35 +606,22 @@ void GccPostProcessor::Private::transGccAnal(Defect *pDef) const
613
606
keyEvt.msg = sm[/* msg */ 1 ];
614
607
}
615
608
616
- void GccPostProcessor::Private::transGccSuffix (Defect *pDef) const
617
- {
618
- if (" COMPILER_WARNING" != pDef->checker )
619
- return ;
620
-
621
- // check for [-W...] suffix in message of the key event
622
- DefEvent &keyEvt = pDef->events [pDef->keyEventIdx ];
623
- boost::smatch sm;
624
- if (!boost::regex_match (keyEvt.msg , sm, this ->reGccWarningEvt ))
625
- return ;
626
-
627
- // append [-W...] to key event ID and remove it from event msg
628
- keyEvt.event += sm[/* id */ 2 ];
629
- // this invalidates sm
630
- keyEvt.msg = sm[/* msg */ 1 ];
631
- }
632
-
633
- void GccPostProcessor::Private::transShellCheckId (Defect *pDef) const
609
+ void GccPostProcessor::Private::transSuffixGeneric (
610
+ Defect *pDef,
611
+ const std::string checker,
612
+ const RE &reEvt)
613
+ const
634
614
{
635
- if (" SHELLCHECK_WARNING " != pDef->checker )
615
+ if (checker != pDef->checker )
636
616
return ;
637
617
638
- // check for [SC1234 ] suffix in message of the key event
618
+ // check for [... ] suffix in message of the key event
639
619
DefEvent &keyEvt = pDef->events [pDef->keyEventIdx ];
640
620
boost::smatch sm;
641
- if (!boost::regex_match (keyEvt.msg , sm, this -> reShellCheckId ))
621
+ if (!boost::regex_match (keyEvt.msg , sm, reEvt ))
642
622
return ;
643
623
644
- // append [SC1234 ] to key event ID and remove it from event msg
624
+ // append [... ] to key event ID and remove it from event msg
645
625
keyEvt.event += sm[/* id */ 2 ];
646
626
// this invalidates sm
647
627
keyEvt.msg = sm[/* msg */ 1 ];
@@ -650,8 +630,8 @@ void GccPostProcessor::Private::transShellCheckId(Defect *pDef) const
650
630
void GccPostProcessor::apply (Defect *pDef) const
651
631
{
652
632
d->transGccAnal (pDef);
653
- d->transGccSuffix (pDef);
654
- d->transShellCheckId (pDef);
633
+ d->transSuffixGeneric (pDef, " COMPILER_WARNING " , d-> reGccWarningEvt );
634
+ d->transSuffixGeneric (pDef, " SHELLCHECK_WARNING " , d-> reShellCheckId );
655
635
d->langDetector .inferLangFromChecker (pDef);
656
636
}
657
637
0 commit comments