Skip to content

Commit 164d969

Browse files
committed
MQE-2047: Static Check Options
- added ruleset reading functionality to static-checks command - added example staticRuleset.json to framework.
1 parent df94717 commit 164d969

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/Magento/FunctionalTestingFramework/Console/StaticChecksCommand.php

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
class StaticChecksCommand extends Command
2424
{
25+
/**
26+
* Associative array containing static ruleset properties.
27+
*
28+
* @var array
29+
*/
30+
private $ruleSet;
31+
2532
/**
2633
* Pool of all existing static check objects
2734
*
@@ -81,6 +88,7 @@ protected function configure()
8188
protected function execute(InputInterface $input, OutputInterface $output)
8289
{
8390
$this->ioStyle = new SymfonyStyle($input, $output);
91+
$this->parseRulesetJson();
8492
try {
8593
$this->validateInput($input);
8694
} catch (InvalidArgumentException $e) {
@@ -133,8 +141,10 @@ private function validateInput(InputInterface $input)
133141
$this->staticCheckObjects = [];
134142
$requiredChecksNames = $input->getArgument('names');
135143
$invalidCheckNames = [];
136-
// Found user required static check script(s) to run,
137-
// If no static check name is supplied, run all static check scripts
144+
// Build list of static check names to run.
145+
if (empty($requiredChecksNames) && isset($this->ruleSet['tests'])) {
146+
$requiredChecksNames = $this->ruleSet['tests'];
147+
}
138148
if (empty($requiredChecksNames)) {
139149
$this->staticCheckObjects = $this->allStaticCheckObjects;
140150
} else {
@@ -164,4 +174,19 @@ private function validateInput(InputInterface $input)
164174
);
165175
}
166176
}
177+
178+
/**
179+
* Parses and sets local ruleSet. If not found, simply returns and lets script continue.
180+
* @return void;
181+
*/
182+
private function parseRulesetJson()
183+
{
184+
$pathToRuleset = FW_BP . DIRECTORY_SEPARATOR . "staticRuleset.json";
185+
if ($pathToRuleset === null) {
186+
$this->ioStyle->text("No ruleset under $pathToRuleset" . PHP_EOL);
187+
return;
188+
}
189+
$this->ioStyle->text("Using ruleset under $pathToRuleset" . PHP_EOL);
190+
$this->ruleSet = json_decode(file_get_contents($pathToRuleset), true);
191+
}
167192
}

staticRuleset.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"tests": [
3+
"actionGroupArguments"
4+
]
5+
}

0 commit comments

Comments
 (0)