Skip to content

Commit

Permalink
Add exclusion option.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrishalbert committed Dec 18, 2018
1 parent 7bdcfff commit ba8beed
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ Give a try, use the included `testcases.php` to generate a report:
*Example: -x="php,inc"*
```

**-e**
```
Exclusion tags that you can add above a line that is being flagged. Most useful for nuances which will remain in subsequent reports.
*Example: -e="@ignoreNextLine"*
Code:
// @ignoreNextLine
foreach ($array as &$byRef) {
```

**--php**
```
File path to the PHP binary to use for syntax checking.
Expand Down
11 changes: 9 additions & 2 deletions classes/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class options {
'f' => [
'option' => self::OPTION_REQUIRED,
'value' => self::VALUE_REQUIRED,
'comment' => 'Path to the file or folder to run against.',
'comment' => 'Path to the files or folders to run against.',
'description' => 'The location of the file or folder to use for generating the report. A fully qualified path is recommended. Relative paths will be based off the php7mar folder.',
'example' => '-f="/path/to/folder"'
'example' => '-f="/path/to/folder,path/to/file"',
],
'r' => [
'option' => self::OPTION_OPTIONAL,
Expand All @@ -78,6 +78,13 @@ class options {
'syntax'
]
],
'e' => [
'option' => self::OPTION_OPTIONAL,
'value' => self::VALUE_REQUIRED,
'comment' => 'Exclusion tag to ignore next line nuance.',
'description' => 'Add // @excludeNextLine on the line above a nuance, for instance, and it will not come up in subsequent results.',
'example' => '-t="@excludeNextLine"'
],
'x' => [
'option' => self::OPTION_OPTIONAL,
'value' => self::VALUE_REQUIRED,
Expand Down
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
],
"require": {
"php": ">=5.4.0"
}
},
"bin": [
"mar.php"
]
}
3 changes: 1 addition & 2 deletions mar.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ private function run() {
// on the line before. -x="@fakeBug" and then on the line before nuance, you can
// include the following and it won't come up in subsequent reports:
// @fakeBug
$exclusionTag = $this->options->getOption('x');
$exclusionTag = is_array($exclusionTag) ? array_shift($exclusionTag) : false;
$exclusionTag = $this->options->getOption('e');
if ($exclusionTag && isset($lines[$index-1]) && strpos($lines[$index-1], $exclusionTag)) {
continue;
}
Expand Down

0 comments on commit ba8beed

Please sign in to comment.