Implement #239
This commit is contained in:
parent
017d208405
commit
77a7b4f5d2
|
@ -115,8 +115,11 @@ void generateReport(string[] fileNames, const StaticAnalysisConfig config)
|
|||
writeln("}");
|
||||
}
|
||||
|
||||
/// For multiple files
|
||||
/// Returns: true if there were errors
|
||||
/**
|
||||
* For multiple files
|
||||
*
|
||||
* Returns: true if there were errors or if there were warnings and `staticAnalyze` was true.
|
||||
*/
|
||||
bool analyze(string[] fileNames, const StaticAnalysisConfig config, bool staticAnalyze = true)
|
||||
{
|
||||
bool hasErrors = false;
|
||||
|
@ -129,10 +132,11 @@ bool analyze(string[] fileNames, const StaticAnalysisConfig config, bool staticA
|
|||
ParseAllocator p = new ParseAllocator;
|
||||
StringCache cache = StringCache(StringCache.defaultBucketCount);
|
||||
uint errorCount = 0;
|
||||
uint warningCount = 0;
|
||||
const Module m = parseModule(fileName, code, p, cache, false, null,
|
||||
&errorCount, null);
|
||||
&errorCount, &warningCount);
|
||||
assert (m);
|
||||
if (errorCount > 0)
|
||||
if (errorCount > 0 || (staticAnalyze && warningCount > 0))
|
||||
hasErrors = true;
|
||||
MessageSet results = analyze(fileName, m, config, staticAnalyze);
|
||||
if (results is null)
|
||||
|
|
15
src/main.d
15
src/main.d
|
@ -182,11 +182,11 @@ int main(string[] args)
|
|||
if (report)
|
||||
generateReport(expandArgs(args), config);
|
||||
else
|
||||
analyze(expandArgs(args), config, true);
|
||||
return analyze(expandArgs(args), config, true) ? 1 : 0;
|
||||
}
|
||||
else if (syntaxCheck)
|
||||
{
|
||||
return .syntaxCheck(expandArgs(args));
|
||||
return .syntaxCheck(expandArgs(args)) ? 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -265,6 +265,7 @@ int main(string[] args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
string[] expandArgs(string[] args)
|
||||
{
|
||||
|
@ -359,11 +360,13 @@ options:
|
|||
--syntaxCheck | -s [sourceFile]
|
||||
Lexes and parses sourceFile, printing the line and column number of any
|
||||
syntax errors to stdout. One error or warning is printed per line.
|
||||
If no files are specified, input is read from stdin.
|
||||
If no files are specified, input is read from stdin. %1$s will exit with
|
||||
a status code of zero if no errors are found, 1 otherwise.
|
||||
|
||||
--styleCheck | -S [sourceFiles]
|
||||
Lexes and parses sourceFiles, printing the line and column number of any
|
||||
static analysis check failures stdout.
|
||||
static analysis check failures stdout. %1$s will exit with a status code
|
||||
of zero if no warnings or errors are found, 1 otherwise.
|
||||
|
||||
--ctags | -c sourceFile
|
||||
Generates ctags information from the given source code file. Note that
|
||||
|
@ -388,7 +391,9 @@ options:
|
|||
current working directory if none are specified.
|
||||
|
||||
--report [sourceFiles sourceDirectories]
|
||||
Generate a static analysis report in JSON format. Implies --styleCheck.
|
||||
Generate a static analysis report in JSON format. Implies --styleCheck,
|
||||
however the exit code will still be zero if errors or warnings are
|
||||
found.
|
||||
|
||||
--config configFile
|
||||
Use the given configuration file instead of the default located in
|
||||
|
|
Loading…
Reference in New Issue