質問

I getting an parse error when I run sonar analysis for file that contains Boost_Foreach instruction

File that contains Boost_Foreach instruction:

    BOOST_FOREACH(SExcludedType entry, excludedFiles)
    {
        CString keyName;
        keyName.Format(format, counter);

        CString textRepresentation = SExcludedType::GetStringRepresentation(entry);
        persistentSettings_.SaveNow(const_cast<PTSTR>(keyName.GetString()), textRepresentation);

        ++counter;
    }

Parse error:

08:18:11.639 ERROR - Unable to parse file: C:\Users\aogonowski\Desktop\Defragler missing files\MainFrame.cpp com.sonar.sslr.api.RecognitionException: Parse error at line 3793 column 1 failed to match all of: RECOVERED_EXPRESSION_STATEMENT STATEMENT

3787: ::GetStringRepresentation(entry); 3788: persistentSettings_.SaveNow(const_cast(keyName.GetString()), textRepresentation); 3789: 3790: ++counter; 3791: } 3792: --> }

Failed at rules: /-RECOVERED_EXPRESSION_STATEMENT consumed from (3782, 2) to (3791, 3): ... ) ) , textRepresentation ) ; ++ counter ; } STATEMENT

I was looking for any solution how to set sonnar to analyse that file but I haven't found any solution expect to comment out that problematic code lines.

役に立ちましたか?

解決

Try setting the property sonar.cxx.defines to BOOST_FOREACH(x,y) in your Sonar runner config file or pom.xml (whatever you are using).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top