jarbin-c-coding-style 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- jarbin_c_coding_style-2.0.0.dist-info/METADATA +150 -0
- jarbin_c_coding_style-2.0.0.dist-info/RECORD +186 -0
- jarbin_c_coding_style-2.0.0.dist-info/WHEEL +4 -0
- jarbin_c_coding_style-2.0.0.dist-info/entry_points.txt +2 -0
- jarbin_c_coding_style-2.0.0.dist-info/licenses/LICENSE +674 -0
- sources/__init__.py +0 -0
- sources/__main__.py +6 -0
- sources/analysis/__init__.py +0 -0
- sources/analysis/directives.py +258 -0
- sources/analysis/lexer.py +288 -0
- sources/analysis/parser.py +1754 -0
- sources/analysis/project.py +286 -0
- sources/analysis/source.py +326 -0
- sources/analysis/syntax.py +238 -0
- sources/analysis/tokens.py +116 -0
- sources/analysis/unit.py +700 -0
- sources/application.py +118 -0
- sources/build_info.json +6 -0
- sources/cli/__init__.py +0 -0
- sources/cli/arguments.py +507 -0
- sources/cli/completion.py +610 -0
- sources/cli/context.py +258 -0
- sources/cli/converters.py +204 -0
- sources/cli/help.py +162 -0
- sources/cli/parser.py +659 -0
- sources/configs/__init__.py +0 -0
- sources/configs/editor.py +207 -0
- sources/configs/ini.py +327 -0
- sources/configs/project.py +735 -0
- sources/configs/schema/__init__.py +0 -0
- sources/configs/schema/project.py +68 -0
- sources/constants.py +801 -0
- sources/diagnostics/__init__.py +0 -0
- sources/diagnostics/fingerprint.py +82 -0
- sources/diagnostics/model.py +146 -0
- sources/engine/__init__.py +0 -0
- sources/engine/api.py +355 -0
- sources/engine/examples.py +157 -0
- sources/engine/outcome.py +114 -0
- sources/engine/plan.py +440 -0
- sources/engine/runner.py +345 -0
- sources/engine/scanner.py +179 -0
- sources/enums.py +838 -0
- sources/errors/__init__.py +0 -0
- sources/errors/exceptions.py +727 -0
- sources/fixers/__init__.py +0 -0
- sources/fixers/base.py +209 -0
- sources/fixers/conflicts.py +129 -0
- sources/fixers/diff.py +73 -0
- sources/fixers/engine.py +434 -0
- sources/fixers/journal.py +290 -0
- sources/fixers/kinds.py +30 -0
- sources/fixers/layout.py +411 -0
- sources/fixers/model.py +151 -0
- sources/fixers/registry.py +54 -0
- sources/fixers/text.py +353 -0
- sources/fixers/verify.py +123 -0
- sources/fixers/writer.py +88 -0
- sources/integrations/__init__.py +0 -0
- sources/integrations/ci/__init__.py +0 -0
- sources/integrations/ci/github.py +183 -0
- sources/integrations/editors/__init__.py +0 -0
- sources/integrations/git/__init__.py +0 -0
- sources/integrations/git/repository.py +176 -0
- sources/integrations/update/__init__.py +0 -0
- sources/integrations/update/installers.py +529 -0
- sources/integrations/update/releases.py +397 -0
- sources/integrations/update/state.py +143 -0
- sources/outputs/__init__.py +0 -0
- sources/outputs/github/__init__.py +0 -0
- sources/outputs/github/renderer.py +135 -0
- sources/outputs/html/__init__.py +0 -0
- sources/outputs/html/renderer.py +694 -0
- sources/outputs/json/__init__.py +0 -0
- sources/outputs/json/renderer.py +154 -0
- sources/outputs/json/report.schema.json +121 -0
- sources/outputs/junit/__init__.py +0 -0
- sources/outputs/junit/renderer.py +151 -0
- sources/outputs/registry.py +135 -0
- sources/outputs/report.py +224 -0
- sources/outputs/sarif/__init__.py +0 -0
- sources/outputs/sarif/renderer.py +182 -0
- sources/outputs/terminal/__init__.py +0 -0
- sources/outputs/terminal/renderer.py +184 -0
- sources/outputs/terminal/style.py +159 -0
- sources/rules/__init__.py +0 -0
- sources/rules/arguments.py +362 -0
- sources/rules/catalog.py +227 -0
- sources/rules/categories/advanced/constant_pointers.ini +46 -0
- sources/rules/categories/advanced/line_break_at_end_of_file.ini +44 -0
- sources/rules/categories/advanced/static.ini +65 -0
- sources/rules/categories/advanced/typing.ini +47 -0
- sources/rules/categories/control_structures/conditional_branching.ini +89 -0
- sources/rules/categories/control_structures/goto.ini +45 -0
- sources/rules/categories/control_structures/ternary_operators.ini +57 -0
- sources/rules/categories/extensions/language_extensions.ini +71 -0
- sources/rules/categories/files_organization/contents_of_the_repository.ini +85 -0
- sources/rules/categories/files_organization/file_coherence.ini +166 -0
- sources/rules/categories/files_organization/file_extension.ini +68 -0
- sources/rules/categories/files_organization/fixtures/program +0 -0
- sources/rules/categories/files_organization/naming_files_and_folders.ini +74 -0
- sources/rules/categories/functions/coherence_of_functions.ini +45 -0
- sources/rules/categories/functions/comments_inside_a_function.ini +45 -0
- sources/rules/categories/functions/functions_without_parameters.ini +39 -0
- sources/rules/categories/functions/naming_functions.ini +79 -0
- sources/rules/categories/functions/number_of_columns.ini +61 -0
- sources/rules/categories/functions/number_of_lines.ini +70 -0
- sources/rules/categories/functions/number_of_parameters.ini +64 -0
- sources/rules/categories/functions/structures_as_parameters.ini +44 -0
- sources/rules/categories/global_scope/constant_values.ini +49 -0
- sources/rules/categories/global_scope/file_header.ini +92 -0
- sources/rules/categories/global_scope/global_variables.ini +53 -0
- sources/rules/categories/global_scope/include.ini +39 -0
- sources/rules/categories/global_scope/indentation_of_preprocessor.ini +62 -0
- sources/rules/categories/global_scope/inline_assembly.ini +43 -0
- sources/rules/categories/global_scope/leading_trailing_lines.ini +58 -0
- sources/rules/categories/global_scope/line_endings.ini +53 -0
- sources/rules/categories/global_scope/separation_of_functions.ini +61 -0
- sources/rules/categories/global_scope/trailing_spaces.ini +45 -0
- sources/rules/categories/header_files/content.ini +104 -0
- sources/rules/categories/header_files/include_guard.ini +47 -0
- sources/rules/categories/header_files/macros.ini +57 -0
- sources/rules/categories/layout_inside_a_function_scope/blank_lines.ini +71 -0
- sources/rules/categories/layout_inside_a_function_scope/code_line_content.ini +112 -0
- sources/rules/categories/layout_inside_a_function_scope/curly_brackets.ini +94 -0
- sources/rules/categories/layout_inside_a_function_scope/indentation.ini +96 -0
- sources/rules/categories/layout_inside_a_function_scope/spaces.ini +113 -0
- sources/rules/categories/layout_inside_a_function_scope/variable_declarations.ini +65 -0
- sources/rules/categories/variables_and_types/naming_identifiers.ini +74 -0
- sources/rules/categories/variables_and_types/pointers.ini +67 -0
- sources/rules/categories/variables_and_types/structures.ini +47 -0
- sources/rules/data/verbs.txt +182 -0
- sources/rules/definition.py +430 -0
- sources/rules/loader.py +925 -0
- sources/rules/paths.py +6 -0
- sources/rules/primitives/__init__.py +0 -0
- sources/rules/primitives/base.py +297 -0
- sources/rules/primitives/braces.py +211 -0
- sources/rules/primitives/directives.py +203 -0
- sources/rules/primitives/indentation.py +376 -0
- sources/rules/primitives/layout.py +199 -0
- sources/rules/primitives/naming.py +277 -0
- sources/rules/primitives/project.py +62 -0
- sources/rules/primitives/registry.py +49 -0
- sources/rules/primitives/repository.py +129 -0
- sources/rules/primitives/review.py +87 -0
- sources/rules/primitives/semantic.py +319 -0
- sources/rules/primitives/spacing.py +210 -0
- sources/rules/primitives/structure.py +586 -0
- sources/rules/primitives/syntax.py +200 -0
- sources/rules/primitives/text.py +408 -0
- sources/rules/primitives/tokens.py +84 -0
- sources/rules/template.py +138 -0
- sources/selftest/__init__.py +0 -0
- sources/selftest/cases.py +292 -0
- sources/services.py +90 -0
- sources/subcommands/__init__.py +0 -0
- sources/subcommands/base.py +45 -0
- sources/subcommands/check/__init__.py +0 -0
- sources/subcommands/check/command.py +45 -0
- sources/subcommands/check/fixing.py +224 -0
- sources/subcommands/check/handler.py +757 -0
- sources/subcommands/info/__init__.py +0 -0
- sources/subcommands/info/command.py +45 -0
- sources/subcommands/info/handler.py +527 -0
- sources/subcommands/registry.py +37 -0
- sources/subcommands/rule/__init__.py +0 -0
- sources/subcommands/rule/command.py +45 -0
- sources/subcommands/rule/handler.py +1067 -0
- sources/subcommands/rule/render.py +273 -0
- sources/subcommands/runner.py +124 -0
- sources/subcommands/test/__init__.py +0 -0
- sources/subcommands/test/command.py +45 -0
- sources/subcommands/test/handler.py +166 -0
- sources/subcommands/test/render.py +219 -0
- sources/subcommands/test/runner.py +430 -0
- sources/subcommands/update/__init__.py +0 -0
- sources/subcommands/update/command.py +45 -0
- sources/subcommands/update/handler.py +408 -0
- sources/utils/__init__.py +0 -0
- sources/utils/build_info.py +188 -0
- sources/utils/git.py +73 -0
- sources/utils/globs.py +98 -0
- sources/utils/logging.py +154 -0
- sources/utils/schema.py +77 -0
- sources/utils/versions.py +87 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = files_organization/contents_of_the_repository
|
|
4
|
+
title = Contents of the repository
|
|
5
|
+
summary = The repository contains no compiled file (.o, .a, .so...), no temporary file (*~, #*#...) and no unnecessary file.
|
|
6
|
+
applies_to = any
|
|
7
|
+
severity = major
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-O1
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[argument:compiled_patterns]
|
|
17
|
+
type = list
|
|
18
|
+
item_type = glob
|
|
19
|
+
default = *.o, *.a, *.so, *.so.*, *.gch, *.pch, *.dll, *.dylib, *.lib, *.obj, *.exe, *.out, a.out
|
|
20
|
+
description = Names of compiled files.
|
|
21
|
+
|
|
22
|
+
[argument:temporary_patterns]
|
|
23
|
+
type = list
|
|
24
|
+
item_type = glob
|
|
25
|
+
default = *~, #*#, .#*, *.swp, *.swo, *.swn, *.tmp, *.bak, *.orig, vgcore.*, *.gcno, *.gcda, *.gcov, .DS_Store
|
|
26
|
+
description = Names of temporary files.
|
|
27
|
+
|
|
28
|
+
[check:compiled]
|
|
29
|
+
kind = path_pattern
|
|
30
|
+
patterns = @compiled_patterns
|
|
31
|
+
message = {code}: compiled file '{path}' in the repository
|
|
32
|
+
|
|
33
|
+
[check:compiled_content]
|
|
34
|
+
kind = content_sniff
|
|
35
|
+
formats = elf, mach_o, pe, archive
|
|
36
|
+
message = {code}: compiled file '{path}' ({value}) in the repository
|
|
37
|
+
|
|
38
|
+
[check:temporary]
|
|
39
|
+
kind = path_pattern
|
|
40
|
+
patterns = @temporary_patterns
|
|
41
|
+
message = {code}: temporary file '{path}' in the repository
|
|
42
|
+
|
|
43
|
+
[check:unnecessary]
|
|
44
|
+
kind = manual_review
|
|
45
|
+
target = file
|
|
46
|
+
where.file_kind = other
|
|
47
|
+
detection = manual
|
|
48
|
+
severity = info
|
|
49
|
+
question = Is '{name}' necessary in the repository?
|
|
50
|
+
|
|
51
|
+
[example:good_1]
|
|
52
|
+
kind = good
|
|
53
|
+
|
|
54
|
+
[example:good_1:file:src/main.c]
|
|
55
|
+
code =
|
|
56
|
+
|int main(void)
|
|
57
|
+
|{
|
|
58
|
+
| return 0;
|
|
59
|
+
|}
|
|
60
|
+
|
|
61
|
+
[example:good_1:file:Makefile]
|
|
62
|
+
code =
|
|
63
|
+
|all:
|
|
64
|
+
|\tcc src/main.c
|
|
65
|
+
|
|
66
|
+
[example:bad_1]
|
|
67
|
+
kind = bad
|
|
68
|
+
expect =
|
|
69
|
+
main.o:1:1:compiled
|
|
70
|
+
main.o:1:1:unnecessary
|
|
71
|
+
main.c~:1:1:temporary
|
|
72
|
+
main.c~:1:1:unnecessary
|
|
73
|
+
program:1:1:compiled_content
|
|
74
|
+
program:1:1:unnecessary
|
|
75
|
+
|
|
76
|
+
[example:bad_1:file:main.o]
|
|
77
|
+
code =
|
|
78
|
+
|object
|
|
79
|
+
|
|
80
|
+
[example:bad_1:file:main.c~]
|
|
81
|
+
code =
|
|
82
|
+
|int main(void);
|
|
83
|
+
|
|
84
|
+
[example:bad_1:file:program]
|
|
85
|
+
fixture = fixtures/program
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = files_organization/file_coherence
|
|
4
|
+
title = File coherence
|
|
5
|
+
summary = A source file matches one logical entity and holds at most 10 functions, including at most 5 non-static functions.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = major
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-O3
|
|
13
|
+
version = 8
|
|
14
|
+
banana = partial
|
|
15
|
+
manual_part = Whether the file matches a logical entity and only groups related functions.
|
|
16
|
+
|
|
17
|
+
[argument:max_functions]
|
|
18
|
+
type = int
|
|
19
|
+
default = 10
|
|
20
|
+
min = 1
|
|
21
|
+
description = Maximum number of functions per file.
|
|
22
|
+
|
|
23
|
+
[argument:max_non_static]
|
|
24
|
+
type = int
|
|
25
|
+
default = 5
|
|
26
|
+
min = 0
|
|
27
|
+
description = Maximum number of non-static functions per file.
|
|
28
|
+
|
|
29
|
+
[check:functions_per_file]
|
|
30
|
+
kind = node_metric
|
|
31
|
+
target = file
|
|
32
|
+
measure = count:function_definition
|
|
33
|
+
max = @max_functions
|
|
34
|
+
message = {code}: {value} functions in this file (max {limit})
|
|
35
|
+
|
|
36
|
+
[check:non_static_per_file]
|
|
37
|
+
kind = node_metric
|
|
38
|
+
target = file
|
|
39
|
+
measure = count:function_definition
|
|
40
|
+
where.storage = not static
|
|
41
|
+
max = @max_non_static
|
|
42
|
+
message = {code}: {value} non-static functions in this file (max {limit})
|
|
43
|
+
|
|
44
|
+
[check:logical_entity]
|
|
45
|
+
kind = manual_review
|
|
46
|
+
target = file
|
|
47
|
+
detection = manual
|
|
48
|
+
severity = info
|
|
49
|
+
question = Does {name} match a single logical entity, grouping only related functions?
|
|
50
|
+
|
|
51
|
+
[example:good_1]
|
|
52
|
+
kind = good
|
|
53
|
+
expect = ok.c:1:1:logical_entity
|
|
54
|
+
|
|
55
|
+
[example:good_1:file:ok.c]
|
|
56
|
+
code =
|
|
57
|
+
|static int get_one(void)
|
|
58
|
+
|{
|
|
59
|
+
| return 1;
|
|
60
|
+
|}
|
|
61
|
+
|
|
|
62
|
+
|int get_two(void)
|
|
63
|
+
|{
|
|
64
|
+
| return get_one() + get_one();
|
|
65
|
+
|}
|
|
66
|
+
|
|
67
|
+
[example:bad_1]
|
|
68
|
+
kind = bad
|
|
69
|
+
expect =
|
|
70
|
+
bad.c:1:1:non_static_per_file
|
|
71
|
+
bad.c:1:1:logical_entity
|
|
72
|
+
|
|
73
|
+
[example:bad_1:file:bad.c]
|
|
74
|
+
code =
|
|
75
|
+
|int get_1(void)
|
|
76
|
+
|{
|
|
77
|
+
| return 1;
|
|
78
|
+
|}
|
|
79
|
+
|
|
|
80
|
+
|int get_2(void)
|
|
81
|
+
|{
|
|
82
|
+
| return 2;
|
|
83
|
+
|}
|
|
84
|
+
|
|
|
85
|
+
|int get_3(void)
|
|
86
|
+
|{
|
|
87
|
+
| return 3;
|
|
88
|
+
|}
|
|
89
|
+
|
|
|
90
|
+
|int get_4(void)
|
|
91
|
+
|{
|
|
92
|
+
| return 4;
|
|
93
|
+
|}
|
|
94
|
+
|
|
|
95
|
+
|int get_5(void)
|
|
96
|
+
|{
|
|
97
|
+
| return 5;
|
|
98
|
+
|}
|
|
99
|
+
|
|
|
100
|
+
|int get_6(void)
|
|
101
|
+
|{
|
|
102
|
+
| return 6;
|
|
103
|
+
|}
|
|
104
|
+
|
|
105
|
+
[example:bad_2]
|
|
106
|
+
kind = bad
|
|
107
|
+
expect =
|
|
108
|
+
many.c:1:1:functions_per_file
|
|
109
|
+
many.c:1:1:logical_entity
|
|
110
|
+
|
|
111
|
+
[example:bad_2:file:many.c]
|
|
112
|
+
code =
|
|
113
|
+
|static int get_1(void)
|
|
114
|
+
|{
|
|
115
|
+
| return 1;
|
|
116
|
+
|}
|
|
117
|
+
|
|
|
118
|
+
|static int get_2(void)
|
|
119
|
+
|{
|
|
120
|
+
| return 2;
|
|
121
|
+
|}
|
|
122
|
+
|
|
|
123
|
+
|static int get_3(void)
|
|
124
|
+
|{
|
|
125
|
+
| return 3;
|
|
126
|
+
|}
|
|
127
|
+
|
|
|
128
|
+
|static int get_4(void)
|
|
129
|
+
|{
|
|
130
|
+
| return 4;
|
|
131
|
+
|}
|
|
132
|
+
|
|
|
133
|
+
|static int get_5(void)
|
|
134
|
+
|{
|
|
135
|
+
| return 5;
|
|
136
|
+
|}
|
|
137
|
+
|
|
|
138
|
+
|static int get_6(void)
|
|
139
|
+
|{
|
|
140
|
+
| return 6;
|
|
141
|
+
|}
|
|
142
|
+
|
|
|
143
|
+
|static int get_7(void)
|
|
144
|
+
|{
|
|
145
|
+
| return 7;
|
|
146
|
+
|}
|
|
147
|
+
|
|
|
148
|
+
|static int get_8(void)
|
|
149
|
+
|{
|
|
150
|
+
| return 8;
|
|
151
|
+
|}
|
|
152
|
+
|
|
|
153
|
+
|static int get_9(void)
|
|
154
|
+
|{
|
|
155
|
+
| return 9;
|
|
156
|
+
|}
|
|
157
|
+
|
|
|
158
|
+
|static int get_10(void)
|
|
159
|
+
|{
|
|
160
|
+
| return 10;
|
|
161
|
+
|}
|
|
162
|
+
|
|
|
163
|
+
|int get_11(void)
|
|
164
|
+
|{
|
|
165
|
+
| return 11;
|
|
166
|
+
|}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = files_organization/file_extension
|
|
4
|
+
title = File extension
|
|
5
|
+
summary = The sources of a C program only have the .c or .h extension.
|
|
6
|
+
applies_to = any
|
|
7
|
+
severity = major
|
|
8
|
+
detection = heuristic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-O2
|
|
13
|
+
version = 8
|
|
14
|
+
banana = none
|
|
15
|
+
manual_part = Whether a file is a source of the C program.
|
|
16
|
+
|
|
17
|
+
[argument:source_patterns]
|
|
18
|
+
type = list
|
|
19
|
+
item_type = glob
|
|
20
|
+
default = *.cpp, *.cc, *.cxx, *.c++, *.C, *.hpp, *.hh, *.hxx, *.h++, *.H, *.inc, *.tpp, *.ipp, *.i
|
|
21
|
+
description = Names of source files with another extension than .c or .h.
|
|
22
|
+
|
|
23
|
+
[check:c_like_extension]
|
|
24
|
+
kind = path_pattern
|
|
25
|
+
patterns = @source_patterns
|
|
26
|
+
severity = info
|
|
27
|
+
message = {code}: source file '{path}' does not have a .c or .h extension
|
|
28
|
+
|
|
29
|
+
[check:c_content]
|
|
30
|
+
kind = content_sniff
|
|
31
|
+
formats = c_source
|
|
32
|
+
where.file_kind = other
|
|
33
|
+
severity = info
|
|
34
|
+
message = {code}: '{path}' contains C code but does not have a .c or .h extension
|
|
35
|
+
|
|
36
|
+
[example:good_1]
|
|
37
|
+
kind = good
|
|
38
|
+
|
|
39
|
+
[example:good_1:file:src/main.c]
|
|
40
|
+
code =
|
|
41
|
+
|#include <stdlib.h>
|
|
42
|
+
|
|
|
43
|
+
|int main(void)
|
|
44
|
+
|{
|
|
45
|
+
| return 0;
|
|
46
|
+
|}
|
|
47
|
+
|
|
48
|
+
[example:good_1:file:README.md]
|
|
49
|
+
code =
|
|
50
|
+
|Run `make` then `./program`.
|
|
51
|
+
|
|
52
|
+
[example:bad_1]
|
|
53
|
+
kind = bad
|
|
54
|
+
expect =
|
|
55
|
+
tools.cpp:1:1:c_like_extension
|
|
56
|
+
tools.cpp:1:1:c_content
|
|
57
|
+
helper.txt:1:1:c_content
|
|
58
|
+
|
|
59
|
+
[example:bad_1:file:tools.cpp]
|
|
60
|
+
code =
|
|
61
|
+
|#include "tools.h"
|
|
62
|
+
|
|
63
|
+
[example:bad_1:file:helper.txt]
|
|
64
|
+
code =
|
|
65
|
+
|int get_one(void)
|
|
66
|
+
|{
|
|
67
|
+
| return 1;
|
|
68
|
+
|}
|
|
Binary file
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = files_organization/naming_files_and_folders
|
|
4
|
+
title = Naming files and folders
|
|
5
|
+
summary = File and folder names are clear, precise, explicit and unambiguous, in English, according to the snake_case convention.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-O4
|
|
13
|
+
version = 8
|
|
14
|
+
banana = partial
|
|
15
|
+
manual_part = Whether names are English, clear, precise, explicit and unambiguous; tolerated abbreviations.
|
|
16
|
+
|
|
17
|
+
[argument:vague_names]
|
|
18
|
+
type = word_set
|
|
19
|
+
default = string, algo, utils, util, misc, tools, helpers, functions, stuff
|
|
20
|
+
description = File names that probably do not define their logical entity.
|
|
21
|
+
|
|
22
|
+
[check:snake_case]
|
|
23
|
+
kind = naming
|
|
24
|
+
target = path_component
|
|
25
|
+
case.file = [a-z0-9_]+
|
|
26
|
+
case.directory = [a-z0-9_]+
|
|
27
|
+
message = {code}: {class} name '{name}' is not in snake_case
|
|
28
|
+
|
|
29
|
+
[check:vague_name]
|
|
30
|
+
kind = naming
|
|
31
|
+
target = path_component
|
|
32
|
+
forbid_names = @vague_names
|
|
33
|
+
forbid_names_in = file
|
|
34
|
+
detection = heuristic
|
|
35
|
+
severity = info
|
|
36
|
+
message = {code}: file name '{name}' does not define the logical entity it represents
|
|
37
|
+
|
|
38
|
+
[check:meaning]
|
|
39
|
+
kind = manual_review
|
|
40
|
+
target = file
|
|
41
|
+
detection = manual
|
|
42
|
+
severity = info
|
|
43
|
+
question = Is the name of {name} (and of its folders) English, clear, precise, explicit and unambiguous?
|
|
44
|
+
|
|
45
|
+
[example:good_1]
|
|
46
|
+
kind = good
|
|
47
|
+
expect =
|
|
48
|
+
src/string_toolbox.c:1:1:meaning
|
|
49
|
+
|
|
50
|
+
[example:good_1:file:src/string_toolbox.c]
|
|
51
|
+
code =
|
|
52
|
+
|int get_length(char const *text);
|
|
53
|
+
|
|
54
|
+
[example:bad_1]
|
|
55
|
+
kind = bad
|
|
56
|
+
expect =
|
|
57
|
+
src/MyFile.c:1:1:snake_case
|
|
58
|
+
src/MyFile.c:1:1:meaning
|
|
59
|
+
Lib-Dir/pathfinding.c:1:1:snake_case
|
|
60
|
+
Lib-Dir/pathfinding.c:1:1:meaning
|
|
61
|
+
src/algo.c:1:1:vague_name
|
|
62
|
+
src/algo.c:1:1:meaning
|
|
63
|
+
|
|
64
|
+
[example:bad_1:file:src/MyFile.c]
|
|
65
|
+
code =
|
|
66
|
+
|int get_one(void);
|
|
67
|
+
|
|
68
|
+
[example:bad_1:file:Lib-Dir/pathfinding.c]
|
|
69
|
+
code =
|
|
70
|
+
|int get_one(void);
|
|
71
|
+
|
|
72
|
+
[example:bad_1:file:src/algo.c]
|
|
73
|
+
code =
|
|
74
|
+
|int get_one(void);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = functions/coherence_of_functions
|
|
4
|
+
title = Coherence of functions
|
|
5
|
+
summary = A function only does one thing, does not mix different levels of abstraction and respects the single-responsibility principle.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = manual
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-F1
|
|
13
|
+
version = 8
|
|
14
|
+
banana = none
|
|
15
|
+
manual_part = Entire rule.
|
|
16
|
+
|
|
17
|
+
[check:single_responsibility]
|
|
18
|
+
kind = manual_review
|
|
19
|
+
target = function_definition
|
|
20
|
+
severity = info
|
|
21
|
+
question = Does '{name}' do only one thing, at one level of abstraction, with a single reason to change?
|
|
22
|
+
|
|
23
|
+
[example:good_1]
|
|
24
|
+
kind = good
|
|
25
|
+
description = Manual checks only produce review items.
|
|
26
|
+
expect = 1:1:single_responsibility
|
|
27
|
+
|
|
28
|
+
[example:good_1:file:one.c]
|
|
29
|
+
code =
|
|
30
|
+
|int get_answer(void)
|
|
31
|
+
|{
|
|
32
|
+
| return 42;
|
|
33
|
+
|}
|
|
34
|
+
|
|
35
|
+
[example:bad_1]
|
|
36
|
+
kind = bad
|
|
37
|
+
description = The review item is the only possible output.
|
|
38
|
+
expect = 1:1:single_responsibility
|
|
39
|
+
|
|
40
|
+
[example:bad_1:file:two.c]
|
|
41
|
+
code =
|
|
42
|
+
|int create_user(char const *name)
|
|
43
|
+
|{
|
|
44
|
+
| return malloc(42) != NULL && allocate_user(name) && my_putstr(name);
|
|
45
|
+
|}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = functions/comments_inside_a_function
|
|
4
|
+
title = Comments inside a function
|
|
5
|
+
summary = There is no comment within a function.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-F8
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[check:comment_in_body]
|
|
17
|
+
kind = token_forbid
|
|
18
|
+
kinds = comment
|
|
19
|
+
where.context = function_body
|
|
20
|
+
message = {code}: comment inside a function
|
|
21
|
+
|
|
22
|
+
[example:good_1]
|
|
23
|
+
kind = good
|
|
24
|
+
|
|
25
|
+
[example:good_1:file:ok.c]
|
|
26
|
+
code =
|
|
27
|
+
|/* Returns the answer. */
|
|
28
|
+
|int get_answer(void)
|
|
29
|
+
|{
|
|
30
|
+
| return 42;
|
|
31
|
+
|}
|
|
32
|
+
|
|
33
|
+
[example:bad_1]
|
|
34
|
+
kind = bad
|
|
35
|
+
expect =
|
|
36
|
+
3:5:comment_in_body
|
|
37
|
+
4:16:comment_in_body
|
|
38
|
+
|
|
39
|
+
[example:bad_1:file:bad.c]
|
|
40
|
+
code =
|
|
41
|
+
|int get_answer(void)
|
|
42
|
+
|{
|
|
43
|
+
| // the answer
|
|
44
|
+
| return 42; /* always */
|
|
45
|
+
|}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = functions/functions_without_parameters
|
|
4
|
+
title = Functions without parameters
|
|
5
|
+
summary = A function (or function pointer) taking no parameters takes void as a parameter in the function declaration.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = major
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-F6
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[check:empty_list]
|
|
17
|
+
kind = node_forbid
|
|
18
|
+
node = parameter_list
|
|
19
|
+
pattern.fields = empty=true
|
|
20
|
+
message = {code}: empty parameter list, write (void)
|
|
21
|
+
|
|
22
|
+
[example:good_1]
|
|
23
|
+
kind = good
|
|
24
|
+
|
|
25
|
+
[example:good_1:file:ok.h]
|
|
26
|
+
code =
|
|
27
|
+
|phys_addr_t alloc_frame(void);
|
|
28
|
+
|void (*on_exit)(void);
|
|
29
|
+
|
|
30
|
+
[example:bad_1]
|
|
31
|
+
kind = bad
|
|
32
|
+
expect =
|
|
33
|
+
1:24:empty_list
|
|
34
|
+
2:16:empty_list
|
|
35
|
+
|
|
36
|
+
[example:bad_1:file:bad.h]
|
|
37
|
+
code =
|
|
38
|
+
|phys_addr_t alloc_frame();
|
|
39
|
+
|void (*on_exit)();
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = functions/naming_functions
|
|
4
|
+
title = Naming functions
|
|
5
|
+
summary = The name of a function defines the task it executes and contains a verb; it is in English, according to the snake_case convention.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-F2
|
|
13
|
+
version = 8
|
|
14
|
+
banana = partial
|
|
15
|
+
manual_part = Whether the name defines the task and is in English; tolerated abbreviations.
|
|
16
|
+
|
|
17
|
+
[argument:verbs]
|
|
18
|
+
type = word_set
|
|
19
|
+
default = file:../../data/verbs.txt
|
|
20
|
+
description = English verbs; a function name must contain one of them.
|
|
21
|
+
|
|
22
|
+
[argument:exempt_names]
|
|
23
|
+
type = list
|
|
24
|
+
default = main
|
|
25
|
+
description = Function names not checked for a verb.
|
|
26
|
+
|
|
27
|
+
[check:snake_case]
|
|
28
|
+
kind = naming
|
|
29
|
+
target = identifier
|
|
30
|
+
case.function = [a-z0-9_]+
|
|
31
|
+
message = {code}: function name '{name}' is not in snake_case
|
|
32
|
+
|
|
33
|
+
[check:verb]
|
|
34
|
+
kind = naming
|
|
35
|
+
target = identifier
|
|
36
|
+
require_word = @verbs
|
|
37
|
+
require_word_in = function
|
|
38
|
+
exempt = @exempt_names
|
|
39
|
+
detection = heuristic
|
|
40
|
+
severity = info
|
|
41
|
+
message = {code}: function name '{name}' does not contain a verb
|
|
42
|
+
|
|
43
|
+
[check:meaning]
|
|
44
|
+
kind = manual_review
|
|
45
|
+
target = function_definition
|
|
46
|
+
detection = manual
|
|
47
|
+
severity = info
|
|
48
|
+
question = Does the name '{name}' define the task the function executes, in English?
|
|
49
|
+
|
|
50
|
+
[example:good_1]
|
|
51
|
+
kind = good
|
|
52
|
+
expect = 1:1:meaning
|
|
53
|
+
|
|
54
|
+
[example:good_1:file:ok.c]
|
|
55
|
+
code =
|
|
56
|
+
|int get_vowels_number(char const *text)
|
|
57
|
+
|{
|
|
58
|
+
| return text[0];
|
|
59
|
+
|}
|
|
60
|
+
|
|
61
|
+
[example:bad_1]
|
|
62
|
+
kind = bad
|
|
63
|
+
expect =
|
|
64
|
+
1:5:verb
|
|
65
|
+
1:1:meaning
|
|
66
|
+
6:5:snake_case
|
|
67
|
+
6:1:meaning
|
|
68
|
+
|
|
69
|
+
[example:bad_1:file:bad.c]
|
|
70
|
+
code =
|
|
71
|
+
|int vowels_nb(char const *text)
|
|
72
|
+
|{
|
|
73
|
+
| return text[0];
|
|
74
|
+
|}
|
|
75
|
+
|
|
|
76
|
+
|int searchShortestPath(void)
|
|
77
|
+
|{
|
|
78
|
+
| return 0;
|
|
79
|
+
|}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = functions/number_of_columns
|
|
4
|
+
title = Number of columns
|
|
5
|
+
summary = The length of a line does not exceed 80 columns; a tab represents 1 character but several columns. It applies to all C files and Makefiles.
|
|
6
|
+
applies_to = c, h, make
|
|
7
|
+
severity = major
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-F3
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[argument:max_columns]
|
|
17
|
+
type = int
|
|
18
|
+
default = 80
|
|
19
|
+
min = 1
|
|
20
|
+
description = Maximum number of columns of a line.
|
|
21
|
+
|
|
22
|
+
[argument:tab_width]
|
|
23
|
+
type = int
|
|
24
|
+
default = 4
|
|
25
|
+
min = 1
|
|
26
|
+
description = Number of columns between two tab stops (not given by the coding style).
|
|
27
|
+
|
|
28
|
+
[check:columns]
|
|
29
|
+
kind = line_metric
|
|
30
|
+
measure = visual_columns
|
|
31
|
+
tab_width = @tab_width
|
|
32
|
+
max = @max_columns
|
|
33
|
+
message = {code}: line is {value} columns long (max {limit})
|
|
34
|
+
|
|
35
|
+
[example:good_1]
|
|
36
|
+
kind = good
|
|
37
|
+
|
|
38
|
+
[example:good_1:file:ok.c]
|
|
39
|
+
code =
|
|
40
|
+
|int main(void)
|
|
41
|
+
|{
|
|
42
|
+
| return 0;
|
|
43
|
+
|}
|
|
44
|
+
|
|
45
|
+
[example:bad_1]
|
|
46
|
+
kind = bad
|
|
47
|
+
expect =
|
|
48
|
+
bad.c:3:81:columns
|
|
49
|
+
Makefile:2:78:columns
|
|
50
|
+
|
|
51
|
+
[example:bad_1:file:bad.c]
|
|
52
|
+
code =
|
|
53
|
+
|int main(void)
|
|
54
|
+
|{
|
|
55
|
+
| return 1000000000 + 1000000000 + 1000000000 + 1000000000 + 1000000000 + 100000;
|
|
56
|
+
|}
|
|
57
|
+
|
|
58
|
+
[example:bad_1:file:Makefile]
|
|
59
|
+
code =
|
|
60
|
+
|all:
|
|
61
|
+
|\tcc -Wall -Wextra -Werror -o program main.c tools.c parser.c lexer.c printer.c
|