Skip to content

Commit 5e9a584

Browse files
authored
[Feature] Suppress error on non-critical rules (#48)
* add non-critical rule * add LintState * add stop_on_first_failure * fix test * fix test * remove risky severity * add test * add test * rename property * rename property * fix tests * remove risky * add option "stop on warning" * move break * move param * fix logger unless lines * fix tests * fix test * use static function * clean config * update rule dumper * add test * add command tester * add covers * add test for exception * add covers * create OneRuleDecoratorRule * add test * add tests * fix lint * fix test * update version
1 parent 1750a0a commit 5e9a584

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+991
-149
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ This file contains changelogs.
44

55
[View all Releases](https://github.com/ArtARTs36/php-merge-request-linter/releases)
66

7+
-----------------------------------------------------------------
8+
9+
## [v0.14.0 (2023-05-27)](https://github.com/ArtARTs36/php-merge-request-linter/compare/0.13.1..0.14.0)
10+
11+
## Added
12+
* Suppress error on non-critical rules via rule option `critical: false`
13+
* Added option `stop_on_failure` for stop linter on first failure
14+
* Added option `stop_on_warning` for stop linter on first warning
15+
16+
[💾 Assets](https://github.com/ArtARTs36/php-merge-request-linter/releases/tag/0.14.0)
17+
18+
719
-----------------------------------------------------------------
820

921
## [v0.13.1 (2023-05-26)](https://github.com/ArtARTs36/php-merge-request-linter/compare/0.13.0..0.13.1)

Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ info:
107107
dump:
108108
./bin/mr-linter dump
109109

110+
dump-docker: docker-build
111+
docker run \
112+
--volume ./:/app \
113+
--entrypoint "make" \
114+
artarts36/merge-request-linter "dump"
115+
110116
push-docs:
111117
php ./vendor/bin/docs-retriever
112118

docs/Builder/ConfigJsonSchema/Generator.php

+19
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,25 @@ public function generate(): JsonSchema
155155
],
156156
], false);
157157

158+
$schema->addProperty('linter', [
159+
'type' => 'object',
160+
'properties' => [
161+
'options' => [
162+
'type' => 'object',
163+
'properties' => [
164+
'stop_on_failure' => [
165+
'type' => 'boolean',
166+
'default' => false,
167+
],
168+
'stop_on_warning' => [
169+
'type' => 'boolean',
170+
'default' => false,
171+
],
172+
],
173+
],
174+
],
175+
], false);
176+
158177
return $schema;
159178
}
160179

docs/Builder/ConfigJsonSchema/RuleSchemaGenerator.php

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ public function generate(JsonSchema $jsonSchema): array
4444
$definition = [
4545
'type' => 'object',
4646
'properties' => [
47+
'critical' => [
48+
'type' => 'boolean',
49+
'default' => true,
50+
],
4751
'when' => [
4852
'description' => 'Conditions that determine whether the rule should run.',
4953
'$ref' => '#/definitions/rule_conditions',

mr-linter-config-schema.json

+158-4
Original file line numberDiff line numberDiff line change
@@ -2397,28 +2397,108 @@
23972397
},
23982398
"additionalProperties": false
23992399
},
2400-
"result.state": {
2400+
"result.state.name": {
24012401
"type": "object",
24022402
"properties": {
24032403
"equals": {
24042404
"description": "Check if value are equal.",
2405-
"type": "boolean"
2405+
"type": "string"
24062406
},
24072407
"=": {
24082408
"description": "Check if value are equal.",
2409-
"type": "boolean"
2409+
"type": "string"
2410+
},
2411+
"lengthMin": {
2412+
"description": "Check the minimum string length.",
2413+
"type": "integer"
2414+
},
2415+
"lengthMax": {
2416+
"description": "Check the maximum string length.",
2417+
"type": "integer"
2418+
},
2419+
"starts": {
2420+
"description": "Check if a string contains a prefix.",
2421+
"type": "string"
2422+
},
2423+
"notStarts": {
2424+
"description": "Check if a string not contains a prefix.",
2425+
"type": "string"
2426+
},
2427+
"ends": {
2428+
"description": "Check if a string contains a suffix.",
2429+
"type": "string"
2430+
},
2431+
"notEnds": {
2432+
"description": "Check if a string not contains a suffix.",
2433+
"type": "string"
2434+
},
2435+
"contains": {
2436+
"description": "Check if a string contains a substring.",
2437+
"type": "string"
24102438
},
24112439
"notEquals": {
24122440
"description": "Check if value are not equal.",
2413-
"type": "boolean"
2441+
"type": "string"
24142442
},
24152443
"!=": {
24162444
"description": "Check if value are not equal.",
2445+
"type": "string"
2446+
},
2447+
"equalsAny": {
2448+
"description": "Check if the field is equal to one of the values.",
2449+
"type": "array",
2450+
"items": {
2451+
"type": "string"
2452+
}
2453+
},
2454+
"match": {
2455+
"description": "Check if a string match a regex.",
2456+
"type": "string"
2457+
},
2458+
"isEmpty": {
2459+
"description": "Check if a value is empty.",
24172460
"type": "boolean"
2461+
},
2462+
"isCamelCase": {
2463+
"description": "Check if a string is camelCase.",
2464+
"type": "boolean"
2465+
},
2466+
"isStudlyCase": {
2467+
"description": "Check if a string is StudlyCase.",
2468+
"type": "boolean"
2469+
},
2470+
"isUpperCase": {
2471+
"description": "Check if a string is upper case.",
2472+
"type": "boolean"
2473+
},
2474+
"isLowerCase": {
2475+
"description": "Check if a string is lower case.",
2476+
"type": "boolean"
2477+
},
2478+
"isSnakeCase": {
2479+
"description": "Check if a string is snake_case.",
2480+
"type": "boolean"
2481+
},
2482+
"isKebabCase": {
2483+
"description": "Check if a string is kebab-case.",
2484+
"type": "boolean"
2485+
},
2486+
"linesMax": {
2487+
"description": "Check the maximum string lines.",
2488+
"type": "integer"
2489+
},
2490+
"containsLine": {
2491+
"description": "Check if a string contains a line.",
2492+
"type": "string"
24182493
}
24192494
},
24202495
"additionalProperties": false
24212496
},
2497+
"result.state.value": {
2498+
"type": "object",
2499+
"properties": [],
2500+
"additionalProperties": false
2501+
},
24222502
"result.notes": {
24232503
"type": "object",
24242504
"properties": {
@@ -2627,6 +2707,24 @@
26272707
}
26282708
}
26292709
}
2710+
},
2711+
"linter": {
2712+
"type": "object",
2713+
"properties": {
2714+
"options": {
2715+
"type": "object",
2716+
"properties": {
2717+
"stop_on_failure": {
2718+
"type": "boolean",
2719+
"default": false
2720+
},
2721+
"stop_on_warning": {
2722+
"type": "boolean",
2723+
"default": false
2724+
}
2725+
}
2726+
}
2727+
}
26302728
}
26312729
},
26322730
"definitions": {
@@ -3608,6 +3706,10 @@
36083706
"rules_properties_@mr-linter_changed_files_limit": {
36093707
"type": "object",
36103708
"properties": {
3709+
"critical": {
3710+
"type": "boolean",
3711+
"default": true
3712+
},
36113713
"when": {
36123714
"description": "Conditions that determine whether the rule should run.",
36133715
"$ref": "#/definitions/rule_conditions"
@@ -3624,6 +3726,10 @@
36243726
"rules_properties_@mr-linter_description_contains_links_of_any_domains": {
36253727
"type": "object",
36263728
"properties": {
3729+
"critical": {
3730+
"type": "boolean",
3731+
"default": true
3732+
},
36273733
"when": {
36283734
"description": "Conditions that determine whether the rule should run.",
36293735
"$ref": "#/definitions/rule_conditions"
@@ -3645,6 +3751,10 @@
36453751
"rules_properties_@mr-linter_description_contains_links_of_all_domains": {
36463752
"type": "object",
36473753
"properties": {
3754+
"critical": {
3755+
"type": "boolean",
3756+
"default": true
3757+
},
36483758
"when": {
36493759
"description": "Conditions that determine whether the rule should run.",
36503760
"$ref": "#/definitions/rule_conditions"
@@ -3666,6 +3776,10 @@
36663776
"rules_properties_@mr-linter_description_not_empty": {
36673777
"type": "object",
36683778
"properties": {
3779+
"critical": {
3780+
"type": "boolean",
3781+
"default": true
3782+
},
36693783
"when": {
36703784
"description": "Conditions that determine whether the rule should run.",
36713785
"$ref": "#/definitions/rule_conditions"
@@ -3676,6 +3790,10 @@
36763790
"rules_properties_@mr-linter_has_all_labels": {
36773791
"type": "object",
36783792
"properties": {
3793+
"critical": {
3794+
"type": "boolean",
3795+
"default": true
3796+
},
36793797
"when": {
36803798
"description": "Conditions that determine whether the rule should run.",
36813799
"$ref": "#/definitions/rule_conditions"
@@ -3697,6 +3815,10 @@
36973815
"rules_properties_@mr-linter_has_any_labels": {
36983816
"type": "object",
36993817
"properties": {
3818+
"critical": {
3819+
"type": "boolean",
3820+
"default": true
3821+
},
37003822
"when": {
37013823
"description": "Conditions that determine whether the rule should run.",
37023824
"$ref": "#/definitions/rule_conditions"
@@ -3707,6 +3829,10 @@
37073829
"rules_properties_@mr-linter_has_any_labels_of": {
37083830
"type": "object",
37093831
"properties": {
3832+
"critical": {
3833+
"type": "boolean",
3834+
"default": true
3835+
},
37103836
"when": {
37113837
"description": "Conditions that determine whether the rule should run.",
37123838
"$ref": "#/definitions/rule_conditions"
@@ -3728,6 +3854,10 @@
37283854
"rules_properties_@mr-linter_jira_has_issue_link": {
37293855
"type": "object",
37303856
"properties": {
3857+
"critical": {
3858+
"type": "boolean",
3859+
"default": true
3860+
},
37313861
"when": {
37323862
"description": "Conditions that determine whether the rule should run.",
37333863
"$ref": "#/definitions/rule_conditions"
@@ -3748,6 +3878,10 @@
37483878
"rules_properties_@mr-linter_youtrack_has_issue_link": {
37493879
"type": "object",
37503880
"properties": {
3881+
"critical": {
3882+
"type": "boolean",
3883+
"default": true
3884+
},
37513885
"when": {
37523886
"description": "Conditions that determine whether the rule should run.",
37533887
"$ref": "#/definitions/rule_conditions"
@@ -3768,6 +3902,10 @@
37683902
"rules_properties_@mr-linter_title_must_starts_with_any_prefix": {
37693903
"type": "object",
37703904
"properties": {
3905+
"critical": {
3906+
"type": "boolean",
3907+
"default": true
3908+
},
37713909
"when": {
37723910
"description": "Conditions that determine whether the rule should run.",
37733911
"$ref": "#/definitions/rule_conditions"
@@ -3789,6 +3927,10 @@
37893927
"rules_properties_@mr-linter_has_changes": {
37903928
"type": "object",
37913929
"properties": {
3930+
"critical": {
3931+
"type": "boolean",
3932+
"default": true
3933+
},
37923934
"when": {
37933935
"description": "Conditions that determine whether the rule should run.",
37943936
"$ref": "#/definitions/rule_conditions"
@@ -3823,6 +3965,10 @@
38233965
"rules_properties_custom": {
38243966
"type": "object",
38253967
"properties": {
3968+
"critical": {
3969+
"type": "boolean",
3970+
"default": true
3971+
},
38263972
"when": {
38273973
"description": "Conditions that determine whether the rule should run.",
38283974
"$ref": "#/definitions/rule_conditions"
@@ -3843,6 +3989,10 @@
38433989
"rules_properties_@mr-linter_title_starts_with_task_number": {
38443990
"type": "object",
38453991
"properties": {
3992+
"critical": {
3993+
"type": "boolean",
3994+
"default": true
3995+
},
38463996
"when": {
38473997
"description": "Conditions that determine whether the rule should run.",
38483998
"$ref": "#/definitions/rule_conditions"
@@ -3859,6 +4009,10 @@
38594009
"rules_properties_@mr-linter_branch_starts_with_task_number": {
38604010
"type": "object",
38614011
"properties": {
4012+
"critical": {
4013+
"type": "boolean",
4014+
"default": true
4015+
},
38624016
"when": {
38634017
"description": "Conditions that determine whether the rule should run.",
38644018
"$ref": "#/definitions/rule_conditions"

0 commit comments

Comments
 (0)