Bailing out if too many (over 12) configurations found froma file. --force parameter added to prevent this from happening.
This commit is contained in:
parent
3a39d18d19
commit
801f2c246d
15
cppcheck.cpp
15
cppcheck.cpp
|
@ -88,6 +88,10 @@ std::string CppCheck::parseFromArgs( int argc, const char* const argv[] )
|
|||
else if (strcmp(argv[i],"-v")==0 || strcmp(argv[i],"--verbose")==0)
|
||||
_settings._verbose = true;
|
||||
|
||||
// Force checking of files that have "too many" configurations
|
||||
else if (strcmp(argv[i],"-f")==0 || strcmp(argv[i],"--force")==0)
|
||||
_settings._force = true;
|
||||
|
||||
else
|
||||
pathnames.push_back( argv[i] );
|
||||
}
|
||||
|
@ -118,6 +122,7 @@ std::string CppCheck::parseFromArgs( int argc, const char* const argv[] )
|
|||
" -q, --quiet Only print error messages\n"
|
||||
" -s, --style Check coding style\n"
|
||||
" -v, --verbose More detailed error reports\n"
|
||||
" -f, --force Force checking on files that have \"too many\" configurations\n"
|
||||
"\n"
|
||||
"Example usage:\n"
|
||||
" # Recursively check ../myproject/ and print only most fatal errors:\n"
|
||||
|
@ -161,8 +166,17 @@ void CppCheck::check()
|
|||
preprocessor.preprocess(fin, fname, filedata, configurations );
|
||||
}
|
||||
|
||||
int checkCount = 0;
|
||||
for ( std::list<std::string>::const_iterator it = configurations.begin(); it != configurations.end(); ++it )
|
||||
{
|
||||
// Check only 12 first configurations, after that bail out, unless --force
|
||||
// was used.
|
||||
if( !_settings._force && checkCount > 11 )
|
||||
{
|
||||
_errorLogger->reportErr( std::string( "Bailing out from checking " ) + fname + ": Too many configurations. Recheck this file with --force if you want to check them all." );
|
||||
break;
|
||||
}
|
||||
|
||||
cfg = *it;
|
||||
std::string codeWithoutCfg = Preprocessor::getcode( filedata, *it );
|
||||
|
||||
|
@ -171,6 +185,7 @@ void CppCheck::check()
|
|||
_errorLogger->reportOut( std::string( "Checking " ) + fname + ": "+cfg+std::string( "..." ) );
|
||||
|
||||
checkFile( codeWithoutCfg, _filenames[c].c_str());
|
||||
checkCount++;
|
||||
}
|
||||
|
||||
if ( _settings._errorsOnly == false && _errout.str().empty() )
|
||||
|
|
|
@ -106,6 +106,7 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<arg choice="opt"><option>--quiet</option></arg>
|
||||
<arg choice="opt"><option>--style</option></arg>
|
||||
<arg choice="opt"><option>--verbose</option></arg>
|
||||
<arg choice="opt"><option>--force</option></arg>
|
||||
<arg choice="opt"><option>file or path</option></arg>
|
||||
<arg choice="plain"><option>...</option></arg>
|
||||
</cmdsynopsis>
|
||||
|
@ -153,6 +154,14 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<para>More detailed error reports</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><option>-f</option></term>
|
||||
<term><option>--force</option></term>
|
||||
<listitem>
|
||||
<para>Force checking of files that have a lot of configurations. Error is printed if such a file is found so there is no reason to use this by
|
||||
default.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
<refsect1 id="author">
|
||||
|
|
|
@ -22,7 +22,7 @@ Compiling
|
|||
Usage
|
||||
|
||||
The syntax is:
|
||||
cppcheck [--all] [--quiet] [--style] [file or path] [file or path]
|
||||
cppcheck [--all] [--quiet] [--style] [--verbose] [--force] [file or path] [file or path]
|
||||
|
||||
The error messages will be printed to stderr.
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ Settings::Settings()
|
|||
_errorsOnly = false;
|
||||
_checkFunctionUsage = false;
|
||||
_verbose = false;
|
||||
_force = false;
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
|
|
|
@ -36,6 +36,9 @@ public:
|
|||
bool _errorsOnly;
|
||||
bool _checkFunctionUsage;
|
||||
bool _verbose;
|
||||
|
||||
/** Force checking t he files with "too many" configurations. */
|
||||
bool _force;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
||||
|
|
Loading…
Reference in New Issue