Skip to content

Commit cc10a65

Browse files
authored
Feat(CI): TwigCS (#49)
1 parent 4676676 commit cc10a65

9 files changed

+106
-36
lines changed

.twig_cs.dist.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use FriendsOfTwig\Twigcs;
6+
7+
$finder = Twigcs\Finder\TemplateFinder::create()
8+
->in(__DIR__ . '/templates')
9+
->name('*.html.twig')
10+
->ignoreVCSIgnored(true);
11+
12+
return Twigcs\Config\Config::create()
13+
->setFinder($finder)
14+
->setRuleSet(\Glpi\Tools\GlpiTwigRuleset::class)
15+
;

composer.json

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
},
55
"require-dev": {
66
"friendsofphp/php-cs-fixer": "^3.75",
7+
"friendsoftwig/twigcs": "^6.1",
78
"glpi-project/tools": "^0.7.4",
89
"php-parallel-lint/php-parallel-lint": "^1.4",
910
"phpstan/extension-installer": "^1.4",
@@ -19,5 +20,10 @@
1920
"allow-plugins": {
2021
"phpstan/extension-installer": true
2122
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"Glpi\\Tools\\": "../../tools/src/"
27+
}
2228
}
2329
}

composer.lock

+57-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/computergroupstatic.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
{{ fields.hiddenField(
6161
'plugin_databaseinventory_computergroups_id',
6262
item.getID(),
63-
)}}
63+
) }}
6464
</div>
6565
</form>
6666
{% endif %}
@@ -103,7 +103,7 @@
103103
{% if checked %}checked="checked"{% endif %}>
104104
</td>
105105
{% endif %}
106-
<td><a href = {{computer['link']}}> {{ computer['name'] }}</a></td>
106+
<td><a href = {{ computer['link'] }}> {{ computer['name'] }}</a></td>
107107
{% if computer['is_dynamic'] == 1 %}
108108
{% set is_dynamic = __('Yes') %}
109109
{% else %}

templates/contactlog.html.twig

+3-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
# -------------------------------------------------------------------------
2727
#}
2828

29-
{% import "components/form/fields_macros.html.twig" as fields %}
30-
3129
{% block more_fields %}
3230
{% if canread %}
3331
{% if contactlogs is not empty %}
@@ -46,11 +44,11 @@
4644
{{ tableheader }}
4745
{% for contactlog in contactlogs %}
4846
<tr>
49-
<td><a href = {{contactlog['linkcred']}}> {{ contactlog['credname'] }}</a></td>
47+
<td><a href = {{ contactlog['linkcred'] }}> {{ contactlog['credname'] }}</a></td>
5048
{% if itemtype == 'Agent' %}
51-
<td><a href = {{contactlog['linkdbparam']}}> {{ contactlog['dbparamname'] }}</a></td>
49+
<td><a href = {{ contactlog['linkdbparam'] }}> {{ contactlog['dbparamname'] }}</a></td>
5250
{% else %}
53-
<td><a href = {{contactlog['linkagent']}}> {{ contactlog['agentname'] }}</a></td>
51+
<td><a href = {{ contactlog['linkagent'] }}> {{ contactlog['agentname'] }}</a></td>
5452
{% endif %}
5553
<td>{{ contactlog['date_creation']|formatted_datetime }}</td>
5654
</tr>

templates/credential.html.twig

+16-19
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,24 @@
3636
item.fields['port'],
3737
__('Port', 'databaseinventory'),
3838
{'min' : 0, 'max' : 99999, 'step' : 1}
39-
)}}
39+
) }}
4040

4141
{{ fields.textField(
42-
'login',
43-
item.fields['login'],
44-
__('Login', 'databaseinventory'),
45-
)
46-
}}
42+
'login',
43+
item.fields['login'],
44+
__('Login', 'databaseinventory'),
45+
) }}
4746

48-
{{ fields.passwordField(
49-
'password',
50-
item.fields['password'],
51-
__('Password', 'databaseinventory'),
52-
{'clearable': true, 'is_disclosable' : false}
53-
)
54-
}}
55-
{{ fields.textField(
56-
'socket',
57-
item.fields['socket'],
58-
__('Socket', 'databaseinventory'),
59-
)
60-
}}
47+
{{ fields.passwordField(
48+
'password',
49+
item.fields['password'],
50+
__('Password', 'databaseinventory'),
51+
{'clearable': true, 'is_disclosable' : false}
52+
) }}
53+
{{ fields.textField(
54+
'socket',
55+
item.fields['socket'],
56+
__('Socket', 'databaseinventory'),
57+
) }}
6158

6259
{% endblock %}

templates/databaseparam.html.twig

+2-3
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@
3535
'partial_inventory',
3636
item.fields['partial_inventory'],
3737
__('Execution frequency for partial inventory', 'databaseinventory'),
38-
)
39-
}}
38+
) }}
4039

4140
{{ fields.dropdownNumberField(
4241
'execution_delay',
4342
item.fields['execution_delay'],
4443
__('Execution delay', 'databaseinventory'),
4544
{'min' : 0, 'max' : 24, 'step' : 1, 'unit' : 'hour'}
46-
)}}
45+
) }}
4746

4847
{% endblock %}

templates/databaseparam_computergroup.html.twig

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
{% set btn_add %}
4848
<button class="btn btn-primary" type="submit" name="add_computergroup" value="1">
4949
<i class="fas fa-plus"></i>
50-
<span>{{_x('button', 'Add') }}</span>
50+
<span>{{ _x('button', 'Add') }}</span>
5151
</button>
5252
{% endset %}
5353

@@ -60,7 +60,7 @@
6060
{{ fields.hiddenField(
6161
'plugin_databaseinventory_databaseparams_id',
6262
item.getID(),
63-
)}}
63+
) }}
6464
</div>
6565
</form>
6666
{% endif %}
@@ -102,7 +102,7 @@
102102
{% if checked %}checked="checked"{% endif %}>
103103
</td>
104104
{% endif %}
105-
<td><a href = {{compgroup['link']}}> {{ compgroup['name'] }}</a></td>
105+
<td><a href = {{ compgroup['link'] }}> {{ compgroup['name'] }}</a></td>
106106
<td>{{ compgroup['comment'] }}</td>
107107
<td>{{ compgroup['nbdynamicitems'] }}</td>
108108
<td>{{ compgroup['nbstaticitems'] }}</td>

templates/databaseparam_credential.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
{{ fields.hiddenField(
6161
'plugin_databaseinventory_databaseparams_id',
6262
item.getID(),
63-
)}}
63+
) }}
6464
</div>
6565
</form>
6666
{% endif %}
@@ -102,7 +102,7 @@
102102
{% if checked %}checked="checked"{% endif %}>
103103
</td>
104104
{% endif %}
105-
<td><a href = {{credential['link']}}> {{ credential['name'] }}</a></td>
105+
<td><a href = {{ credential['link'] }}> {{ credential['name'] }}</a></td>
106106
<td>{{ credential['login'] }}</td>
107107
<td>{{ credential['port'] }}</td>
108108
<td>{{ credential['socket'] }}</td>

0 commit comments

Comments
 (0)