1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/** |
3
|
|
|
* @author Marcel Bolten <[email protected]> |
4
|
|
|
* @copyright 2023 Nicolas CARPi |
5
|
|
|
* @see https://www.elabftw.net Official website |
6
|
|
|
* @license AGPL-3.0 |
7
|
|
|
* @package elabftw |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace FriendsOfTwig\Twigcs\Ruleset; |
11
|
|
|
|
12
|
|
|
use FriendsOfTwig\Twigcs\RegEngine\RulesetBuilder; |
|
|
|
|
13
|
|
|
use FriendsOfTwig\Twigcs\RegEngine\RulesetConfigurator; |
|
|
|
|
14
|
|
|
use FriendsOfTwig\Twigcs\Rule; |
15
|
|
|
use FriendsOfTwig\Twigcs\TemplateResolver\NullResolver; |
|
|
|
|
16
|
|
|
use FriendsOfTwig\Twigcs\TemplateResolver\TemplateResolverInterface; |
|
|
|
|
17
|
|
|
use FriendsOfTwig\Twigcs\Validator\Violation; |
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* eLabFTW ruleset for twigcs |
21
|
|
|
*/ |
22
|
|
|
class ELabFtwRuleset implements RulesetInterface, TemplateResolverAwareInterface |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
private TemplateResolverInterface $resolver; |
25
|
|
|
|
26
|
|
|
public function __construct(private int $twigMajorVersion) |
27
|
|
|
{ |
28
|
|
|
$this->resolver = new NullResolver(); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function getRules() |
32
|
|
|
{ |
33
|
|
|
$configurator = new RulesetConfigurator(); |
34
|
|
|
$configurator->setTwigMajorVersion($this->twigMajorVersion); |
35
|
|
|
$builder = new RulesetBuilder($configurator); |
36
|
|
|
|
37
|
|
|
return array( |
38
|
|
|
new Rule\ForbiddenFunctions(Violation::SEVERITY_ERROR, array('dump')), |
|
|
|
|
39
|
|
|
// allow CamelCase, deactivate Rule\LowerCaseVariable |
40
|
|
|
//new Rule\LowerCaseVariable(Violation::SEVERITY_ERROR), |
41
|
|
|
new Rule\RegEngineRule(Violation::SEVERITY_ERROR, $builder->build()), |
|
|
|
|
42
|
|
|
new Rule\TrailingSpace(Violation::SEVERITY_ERROR), |
|
|
|
|
43
|
|
|
new Rule\UnusedMacro(Violation::SEVERITY_WARNING, $this->resolver), |
|
|
|
|
44
|
|
|
new Rule\UnusedVariable(Violation::SEVERITY_WARNING, $this->resolver), |
|
|
|
|
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function setTemplateResolver(TemplateResolverInterface $resolver): void |
49
|
|
|
{ |
50
|
|
|
$this->resolver = $resolver; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths