Skip to content

Commit

Permalink
Merge branch 'master' into jgardiner/improved-null-checking
Browse files Browse the repository at this point in the history
  • Loading branch information
jongardiner authored May 10, 2024
2 parents 7f34b8e + fded0c9 commit 97945c7
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 33 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,35 +275,37 @@ Note: Command line usage will probably change significantly in the v1.0 release.
<pre>
Usage: php -d memory_limit=500M vendor/bin/guardrail.php [-a] [-i] [-n #] [-o output_file_name] [-p #/#] config_file

where: -p #/# = Define the number of partitions and the current partition.
Use for multiple hosts. Example: -p 1/4
where: -p #/# = Define the number of partitions and the current partition.
Use for multiple hosts. Example: -p 1/4

-n # = number of child process to run.
Use for multiple processes on a single host. A good rule of thumb is 1 process per CPU core.
-n # = number of child process to run.
Use for multiple processes on a single host. A good rule of thumb is 1 process per CPU core.

-a = run the "analyze" operation
-a = run the "analyze" operation

-i = run the "index" operation.
Defaults to yes if using in memory index.
-i = run the "index" operation.
Defaults to yes if using in memory index.

--diff patch_file = Allows you to limit results to only those errors occuring on
lines in a particular patch set. Requires unified diff format taken
from the root directory of the project. Must set emit { "when": "new" }
for each error that you want to emit in this fashion.
--diff patch_file = Allows you to limit results to only those errors occuring on
lines in a particular patch set. Requires unified diff format taken
from the root directory of the project. Must set emit { "when": "new" }
for each error that you want to emit in this fashion.

--format format = Select choose between "xunit", "text", or "counts"
--format format = Select choose between "xunit", "text", or "counts"

-s = prefer sqlite index
-s = prefer sqlite index

-m = prefer in memory index (only available when -n=1 and -p=1/1)
-m = prefer in memory index (only available when -n=1 and -p=1/1)

-o output_file_name = Output results in junit format to the specified filename

-o output_file_name = Output results in junit format to the specified filename

--metric-output = Output results to the specified filename

--symbol-table-output = Output results to the specified filename

-v = Increase verbosity level. Can be used once or twice.
-v = Increase verbosity level. Can be used once or twice.

-h or --help = Ignore all other options and show this page.
-h or --help = Ignore all other options and show this page.


</pre>
Expand Down
32 changes: 18 additions & 14 deletions src/CommandLineRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,36 @@ public function usage() {
echo "
Usage: php guardrail.phar [-a] [-i] [-n #] [--format xunit|text] [-o output_file_name] [-p #/#] [--timings] config_file
where: -p #/# = Define the number of partitions and the current partition.
where: -p #/# = Define the number of partitions and the current partition.
Use for multiple hosts. Example: -p 1/4
--format {format} = Use \"xunit\" format or a more console friendly \"text\" format
--format {format} = Use \"xunit\" format or a more console friendly \"text\" format
-n # = number of child process to run.
Use for multiple processes on a single host.
-n # = number of child process to run.
Use for multiple processes on a single host.
-a = run the \"analyze\" operation
-a = run the \"analyze\" operation
-i = run the \"index\" operation.
Defaults to yes if using in memory index.
-i = run the \"index\" operation.
Defaults to yes if using in memory index.
-j = prefer json index
-j = prefer json index
-m = prefer in memory index (only available when -n=1 and -p=1/1)
-m = prefer in memory index (only available when -n=1 and -p=1/1)
-o output_file_name = Output results to the specified filename
-o output_file_name = Output results to the specified filename
-v = Increase verbosity level. Can be used once or twice.
--metric-output = Output results to the specified filename
-h or --help = Ignore all other options and show this page.
--symbol-table-output = Output results to the specified filename
-v = Increase verbosity level. Can be used once or twice.
-h or --help = Ignore all other options and show this page.
-l or --list = Ignore all other options and list standard test names.
-l or --list = Ignore all other options and list standard test names.
--timings = Output a summary of how long each check ran for.
--timings = Output a summary of how long each check ran for.
";
}

Expand Down
24 changes: 23 additions & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ class Config {
/** @var string */
private $outputFile = "";

/** @var string */
private $metricOutputFile = "";

/** @var string */
private $symbolTableOutputFile = "";

/** @var int MEMORY_SYMBOL_TABLE | SQLITE_SYMBOL_TABLE */
private $preferredTable = self::MEMORY_SYMBOL_TABLE;

Expand Down Expand Up @@ -353,6 +359,18 @@ private function parseArgv(array $argv) {
}
$this->outputFile = $argv[++$argCount];
break;
case '--metric-output':
if ($argCount + 1 >= count($argv)) {
throw new InvalidConfigException;
}
$this->metricOutputFile = $argv[++$argCount];
break;
case '--symbol-table-output':
if ($argCount + 1 >= count($argv)) {
throw new InvalidConfigException;
}
$this->symbolTableOutputFile = $argv[++$argCount];
break;
case '--diff':
if ($argCount + 1 >= count($argv)) {
throw new InvalidConfigException();
Expand Down Expand Up @@ -502,6 +520,10 @@ public function getOutputFormat() {
* @return string
*/
private function getSymbolTableFile() {
if (!empty($this->symbolTableOutputFile)) {
return $this->symbolTableOutputFile;
}

return $this->basePath . "/" . $this->symbolTableFile . ".json";
}

Expand Down Expand Up @@ -551,6 +573,6 @@ public function getOutputFile() {
}

public function getMetricOutputFile() {
return "metrics.json";
return $this->metricOutputFile ?: "metrics.json";
}
}

0 comments on commit 97945c7

Please sign in to comment.