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,113 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = layout_inside_a_function_scope/spaces
|
|
4
|
+
title = Spaces
|
|
5
|
+
summary = One and only one space is used as a separator, never a tabulation. A space follows a comma or a keyword with arguments; no space between a function name and its bracket, after a unary operator, before a semicolon or a comma. In a for, a semicolon not immediately followed by another one is followed by a space. Binary and ternary operators have a space on both sides; else is surrounded by spaces.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-L3
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[check:separator]
|
|
17
|
+
kind = spacing
|
|
18
|
+
classes = separator, tab_separator
|
|
19
|
+
message = {code}: use one and only one space as a separator
|
|
20
|
+
fix = safe
|
|
21
|
+
fix.kind = fix_spacing
|
|
22
|
+
|
|
23
|
+
[check:comma]
|
|
24
|
+
kind = spacing
|
|
25
|
+
classes = comma
|
|
26
|
+
message = {code}: no space before a comma and one space after it
|
|
27
|
+
fix = safe
|
|
28
|
+
fix.kind = fix_spacing
|
|
29
|
+
|
|
30
|
+
[check:semicolon]
|
|
31
|
+
kind = spacing
|
|
32
|
+
classes = semicolon, for_semicolon
|
|
33
|
+
message = {code}: no space before a semicolon (and one space after it in a for)
|
|
34
|
+
fix = safe
|
|
35
|
+
fix.kind = fix_spacing
|
|
36
|
+
|
|
37
|
+
[check:keyword]
|
|
38
|
+
kind = spacing
|
|
39
|
+
classes = keyword, else
|
|
40
|
+
message = {code}: missing space around keyword '{name}'
|
|
41
|
+
fix = safe
|
|
42
|
+
fix.kind = fix_spacing
|
|
43
|
+
|
|
44
|
+
[check:function_bracket]
|
|
45
|
+
kind = spacing
|
|
46
|
+
classes = call_paren
|
|
47
|
+
message = {code}: no space between a function name and its bracket
|
|
48
|
+
fix = safe
|
|
49
|
+
fix.kind = fix_spacing
|
|
50
|
+
|
|
51
|
+
[check:unary_operator]
|
|
52
|
+
kind = spacing
|
|
53
|
+
classes = unary_operator
|
|
54
|
+
message = {code}: no space after the unary operator '{name}'
|
|
55
|
+
fix = safe
|
|
56
|
+
fix.kind = fix_spacing
|
|
57
|
+
|
|
58
|
+
[check:binary_operator]
|
|
59
|
+
kind = spacing
|
|
60
|
+
classes = binary_operator, ternary_operator
|
|
61
|
+
message = {code}: operator '{name}' must have one space on both sides
|
|
62
|
+
fix = safe
|
|
63
|
+
fix.kind = fix_spacing
|
|
64
|
+
|
|
65
|
+
[example:good_1]
|
|
66
|
+
kind = good
|
|
67
|
+
|
|
68
|
+
[example:good_1:file:ok.c]
|
|
69
|
+
code =
|
|
70
|
+
|int compute(char const *str, int term1, int term2)
|
|
71
|
+
|{
|
|
72
|
+
| int sum = 0;
|
|
73
|
+
| size_t s = sizeof(struct file);
|
|
74
|
+
|
|
|
75
|
+
| for (size_t i = 0; str[i] != '\\0'; i++)
|
|
76
|
+
| sum = term1 + 2 * term2;
|
|
77
|
+
| add_numbers(1, 2);
|
|
78
|
+
| if (!sum)
|
|
79
|
+
| return 1;
|
|
80
|
+
| else
|
|
81
|
+
| sum = -sum;
|
|
82
|
+
| return (sum > 0 ? sum : (int)s);
|
|
83
|
+
|}
|
|
84
|
+
|
|
85
|
+
[example:bad_1]
|
|
86
|
+
kind = bad
|
|
87
|
+
expect =
|
|
88
|
+
3:5:keyword
|
|
89
|
+
4:19:comma
|
|
90
|
+
5:16:binary_operator
|
|
91
|
+
5:18:binary_operator
|
|
92
|
+
6:9:unary_operator
|
|
93
|
+
7:11:semicolon
|
|
94
|
+
8:18:semicolon
|
|
95
|
+
9:13:semicolon
|
|
96
|
+
10:16:function_bracket
|
|
97
|
+
11:7:binary_operator
|
|
98
|
+
11:8:separator
|
|
99
|
+
|
|
100
|
+
[example:bad_1:file:bad.c]
|
|
101
|
+
code =
|
|
102
|
+
|void compute(void)
|
|
103
|
+
|{
|
|
104
|
+
| return(1);
|
|
105
|
+
| add_numbers(1 , 2);
|
|
106
|
+
| sum = term1+2*term2;
|
|
107
|
+
| s = sizeof (struct file);
|
|
108
|
+
| break ;
|
|
109
|
+
| for (size_t i;str[i] != '\\0'; i++)
|
|
110
|
+
| i++ ;
|
|
111
|
+
| my_putchar ('a');
|
|
112
|
+
| a = 3;
|
|
113
|
+
|}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = layout_inside_a_function_scope/variable_declarations
|
|
4
|
+
title = Variable declarations
|
|
5
|
+
summary = Variables are declared at the beginning of the function, only one per statement; a for loop may declare a variable in its initialization part.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = major
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-L5
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[check:beginning_of_function]
|
|
17
|
+
kind = node_forbid
|
|
18
|
+
node = declaration, type_definition
|
|
19
|
+
pattern.fields = misplaced_declaration=true
|
|
20
|
+
message = {code}: variable declared after the beginning of the function
|
|
21
|
+
|
|
22
|
+
[check:one_per_statement]
|
|
23
|
+
kind = node_forbid
|
|
24
|
+
node = declaration
|
|
25
|
+
pattern.fields = declarator_count>1, in_function=true
|
|
26
|
+
message = {code}: several variables declared in one statement
|
|
27
|
+
|
|
28
|
+
[example:good_1]
|
|
29
|
+
kind = good
|
|
30
|
+
|
|
31
|
+
[example:good_1:file:ok.c]
|
|
32
|
+
code =
|
|
33
|
+
|int main(void)
|
|
34
|
+
|{
|
|
35
|
+
| int forty_two = 42;
|
|
36
|
+
| int max = 12;
|
|
37
|
+
|
|
|
38
|
+
| for (unsigned int i = 0; i < max; i++) {
|
|
39
|
+
| calculate_gcd(forty_two, max);
|
|
40
|
+
| }
|
|
41
|
+
| return 0;
|
|
42
|
+
|}
|
|
43
|
+
|
|
44
|
+
[example:bad_1]
|
|
45
|
+
kind = bad
|
|
46
|
+
expect =
|
|
47
|
+
3:5:one_per_statement
|
|
48
|
+
7:5:beginning_of_function
|
|
49
|
+
|
|
50
|
+
[example:bad_1:file:bad.c]
|
|
51
|
+
code =
|
|
52
|
+
|long calculate_gcd(long a, long b)
|
|
53
|
+
|{
|
|
54
|
+
| long biggest, smallest;
|
|
55
|
+
|
|
|
56
|
+
| biggest = MAX(a, b);
|
|
57
|
+
| smallest = MIN(a, b);
|
|
58
|
+
| long rest;
|
|
59
|
+
| while (smallest > 0) {
|
|
60
|
+
| rest = biggest % smallest;
|
|
61
|
+
| biggest = smallest;
|
|
62
|
+
| smallest = rest;
|
|
63
|
+
| }
|
|
64
|
+
| return a;
|
|
65
|
+
|}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = variables_and_types/naming_identifiers
|
|
4
|
+
title = Naming identifiers
|
|
5
|
+
summary = Identifiers are in English, in snake_case; typedef type names end with _t; macros, global constants and enum contents are in UPPER_SNAKE_CASE.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-V1
|
|
13
|
+
version = 8
|
|
14
|
+
banana = partial
|
|
15
|
+
manual_part = Whether names are English; tolerated abbreviations.
|
|
16
|
+
|
|
17
|
+
[check:snake_case]
|
|
18
|
+
kind = naming
|
|
19
|
+
target = identifier
|
|
20
|
+
case.variable = [a-z0-9_]+
|
|
21
|
+
case.parameter = [a-z0-9_]+
|
|
22
|
+
case.field = [a-z0-9_]+
|
|
23
|
+
case.tag = [a-z0-9_]+
|
|
24
|
+
case.label = [a-z0-9_]+
|
|
25
|
+
case.macro_parameter = [a-z0-9_]+
|
|
26
|
+
message = {code}: {class} name '{name}' is not in snake_case
|
|
27
|
+
|
|
28
|
+
[check:typedef]
|
|
29
|
+
kind = naming
|
|
30
|
+
target = identifier
|
|
31
|
+
case.typedef = [a-z0-9_]*_t
|
|
32
|
+
message = {code}: type name '{name}' must be in snake_case and end with _t
|
|
33
|
+
|
|
34
|
+
[check:upper_snake_case]
|
|
35
|
+
kind = naming
|
|
36
|
+
target = identifier
|
|
37
|
+
case.macro = [A-Z0-9_]+
|
|
38
|
+
case.constant = [A-Z0-9_]+
|
|
39
|
+
case.enumerator = [A-Z0-9_]+
|
|
40
|
+
message = {code}: {class} name '{name}' is not in UPPER_SNAKE_CASE
|
|
41
|
+
|
|
42
|
+
[example:good_1]
|
|
43
|
+
kind = good
|
|
44
|
+
|
|
45
|
+
[example:good_1:file:ok.h]
|
|
46
|
+
code =
|
|
47
|
+
|#define IS_PAGE_ALIGNED(x) (!((x) & (PAGE_SIZE - 1)))
|
|
48
|
+
|enum arch {
|
|
49
|
+
| I386 = 0,
|
|
50
|
+
| X86_64,
|
|
51
|
+
|};
|
|
52
|
+
|const float PI = 3.14159;
|
|
53
|
+
|typedef struct int_couple pixel_t;
|
|
54
|
+
|int get_value(int raw_value);
|
|
55
|
+
|
|
56
|
+
[example:bad_1]
|
|
57
|
+
kind = bad
|
|
58
|
+
expect =
|
|
59
|
+
1:9:upper_snake_case
|
|
60
|
+
1:20:snake_case
|
|
61
|
+
3:5:upper_snake_case
|
|
62
|
+
5:13:typedef
|
|
63
|
+
6:11:upper_snake_case
|
|
64
|
+
7:5:snake_case
|
|
65
|
+
|
|
66
|
+
[example:bad_1:file:bad.h]
|
|
67
|
+
code =
|
|
68
|
+
|#define is_aligned(X) (!(X))
|
|
69
|
+
|enum arch {
|
|
70
|
+
| i386 = 0,
|
|
71
|
+
|};
|
|
72
|
+
|typedef int age;
|
|
73
|
+
|const int answer = 42;
|
|
74
|
+
|int myCounter;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = variables_and_types/pointers
|
|
4
|
+
title = Pointers
|
|
5
|
+
summary = In pointer context, the asterisk is attached to the identifier on its right, and preceded by a space unless it follows an opening parenthesis or another asterisk; in a cast it has a space on its left but not on its right.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = minor
|
|
8
|
+
detection = automatic
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-V3
|
|
13
|
+
version = 8
|
|
14
|
+
banana = full
|
|
15
|
+
|
|
16
|
+
[check:asterisk]
|
|
17
|
+
kind = spacing
|
|
18
|
+
classes = pointer_star
|
|
19
|
+
message = {code}: misplaced pointer asterisk
|
|
20
|
+
fix = safe
|
|
21
|
+
fix.kind = fix_spacing
|
|
22
|
+
|
|
23
|
+
[example:good_1]
|
|
24
|
+
kind = good
|
|
25
|
+
|
|
26
|
+
[example:good_1:file:ok.c]
|
|
27
|
+
code =
|
|
28
|
+
|int strlen(char const *str);
|
|
29
|
+
|char *nbr_to_str(int i);
|
|
30
|
+
|
|
|
31
|
+
|int main(int argc, char **argv)
|
|
32
|
+
|{
|
|
33
|
+
| int *a;
|
|
34
|
+
| char *const *array;
|
|
35
|
+
| int b = 3 * argc;
|
|
36
|
+
| void (*func_ptr)(int) = &func;
|
|
37
|
+
|
|
|
38
|
+
| my_put_nbr(*a);
|
|
39
|
+
| return (int *)a == NULL;
|
|
40
|
+
|}
|
|
41
|
+
|
|
42
|
+
[example:bad_1]
|
|
43
|
+
kind = bad
|
|
44
|
+
expect =
|
|
45
|
+
1:22:asterisk
|
|
46
|
+
2:5:asterisk
|
|
47
|
+
6:8:asterisk
|
|
48
|
+
7:10:asterisk
|
|
49
|
+
9:11:asterisk
|
|
50
|
+
11:16:asterisk
|
|
51
|
+
12:16:asterisk
|
|
52
|
+
|
|
53
|
+
[example:bad_1:file:bad.c]
|
|
54
|
+
code =
|
|
55
|
+
|int strlen(char const* str);
|
|
56
|
+
|char* nbr_to_str(int i);
|
|
57
|
+
|
|
|
58
|
+
|int main(int argc, char **argv)
|
|
59
|
+
|{
|
|
60
|
+
| int* a;
|
|
61
|
+
| char * const *array;
|
|
62
|
+
| int b = 3*argc;
|
|
63
|
+
| void (* func_ptr)(int) = &func;
|
|
64
|
+
|
|
|
65
|
+
| my_put_nbr(* a);
|
|
66
|
+
| return (int*)a == NULL;
|
|
67
|
+
|}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[rule]
|
|
2
|
+
schema = 2
|
|
3
|
+
id = variables_and_types/structures
|
|
4
|
+
title = Structures
|
|
5
|
+
summary = Variables are grouped into a structure if and only if they form a coherent entity; structures are kept as small as possible.
|
|
6
|
+
applies_to = c, h
|
|
7
|
+
severity = major
|
|
8
|
+
detection = manual
|
|
9
|
+
status = stable
|
|
10
|
+
|
|
11
|
+
[epitech]
|
|
12
|
+
ref = C-V2
|
|
13
|
+
version = 8
|
|
14
|
+
banana = none
|
|
15
|
+
manual_part = Entire rule.
|
|
16
|
+
|
|
17
|
+
[check:coherent_entity]
|
|
18
|
+
kind = manual_review
|
|
19
|
+
target = struct_definition
|
|
20
|
+
severity = info
|
|
21
|
+
question = Do the fields of '{name}' form a coherent entity, kept as small as possible?
|
|
22
|
+
|
|
23
|
+
[example:good_1]
|
|
24
|
+
kind = good
|
|
25
|
+
expect = 1:1:coherent_entity
|
|
26
|
+
|
|
27
|
+
[example:good_1:file:person.h]
|
|
28
|
+
code =
|
|
29
|
+
|struct person {
|
|
30
|
+
| char *name;
|
|
31
|
+
| unsigned int age;
|
|
32
|
+
| float salary;
|
|
33
|
+
|};
|
|
34
|
+
|
|
35
|
+
[example:bad_1]
|
|
36
|
+
kind = bad
|
|
37
|
+
expect = 1:1:coherent_entity
|
|
38
|
+
|
|
39
|
+
[example:bad_1:file:data.h]
|
|
40
|
+
code =
|
|
41
|
+
|struct data {
|
|
42
|
+
| struct person player;
|
|
43
|
+
| unsigned int width;
|
|
44
|
+
| unsigned int length;
|
|
45
|
+
| unsigned int score;
|
|
46
|
+
| int i;
|
|
47
|
+
|};
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# English verbs accepted in function names (C-F2 heuristic). One word per line.
|
|
2
|
+
# Edit through the `require_word` argument of functions/naming_functions to extend it.
|
|
3
|
+
abort
|
|
4
|
+
accept
|
|
5
|
+
access
|
|
6
|
+
add
|
|
7
|
+
adjust
|
|
8
|
+
alloc
|
|
9
|
+
allocate
|
|
10
|
+
append
|
|
11
|
+
apply
|
|
12
|
+
assign
|
|
13
|
+
attach
|
|
14
|
+
build
|
|
15
|
+
calc
|
|
16
|
+
calculate
|
|
17
|
+
call
|
|
18
|
+
cancel
|
|
19
|
+
cat
|
|
20
|
+
change
|
|
21
|
+
check
|
|
22
|
+
clean
|
|
23
|
+
clear
|
|
24
|
+
clone
|
|
25
|
+
close
|
|
26
|
+
cmp
|
|
27
|
+
compare
|
|
28
|
+
compute
|
|
29
|
+
concat
|
|
30
|
+
connect
|
|
31
|
+
convert
|
|
32
|
+
copy
|
|
33
|
+
count
|
|
34
|
+
create
|
|
35
|
+
cut
|
|
36
|
+
decode
|
|
37
|
+
decrypt
|
|
38
|
+
delete
|
|
39
|
+
destroy
|
|
40
|
+
detach
|
|
41
|
+
detect
|
|
42
|
+
display
|
|
43
|
+
divide
|
|
44
|
+
do
|
|
45
|
+
draw
|
|
46
|
+
dump
|
|
47
|
+
dup
|
|
48
|
+
duplicate
|
|
49
|
+
edit
|
|
50
|
+
emit
|
|
51
|
+
enable
|
|
52
|
+
encode
|
|
53
|
+
encrypt
|
|
54
|
+
end
|
|
55
|
+
ensure
|
|
56
|
+
enter
|
|
57
|
+
erase
|
|
58
|
+
eval
|
|
59
|
+
evaluate
|
|
60
|
+
execute
|
|
61
|
+
exec
|
|
62
|
+
exit
|
|
63
|
+
expand
|
|
64
|
+
extract
|
|
65
|
+
fetch
|
|
66
|
+
fill
|
|
67
|
+
filter
|
|
68
|
+
find
|
|
69
|
+
finish
|
|
70
|
+
fix
|
|
71
|
+
flush
|
|
72
|
+
format
|
|
73
|
+
free
|
|
74
|
+
generate
|
|
75
|
+
get
|
|
76
|
+
go
|
|
77
|
+
grow
|
|
78
|
+
handle
|
|
79
|
+
has
|
|
80
|
+
hash
|
|
81
|
+
hide
|
|
82
|
+
init
|
|
83
|
+
initialize
|
|
84
|
+
insert
|
|
85
|
+
is
|
|
86
|
+
join
|
|
87
|
+
jump
|
|
88
|
+
keep
|
|
89
|
+
kill
|
|
90
|
+
launch
|
|
91
|
+
leave
|
|
92
|
+
list
|
|
93
|
+
load
|
|
94
|
+
lock
|
|
95
|
+
log
|
|
96
|
+
lookup
|
|
97
|
+
loop
|
|
98
|
+
make
|
|
99
|
+
manage
|
|
100
|
+
map
|
|
101
|
+
match
|
|
102
|
+
merge
|
|
103
|
+
move
|
|
104
|
+
multiply
|
|
105
|
+
new
|
|
106
|
+
next
|
|
107
|
+
normalize
|
|
108
|
+
notify
|
|
109
|
+
open
|
|
110
|
+
pack
|
|
111
|
+
parse
|
|
112
|
+
pause
|
|
113
|
+
peek
|
|
114
|
+
pick
|
|
115
|
+
play
|
|
116
|
+
pop
|
|
117
|
+
prepare
|
|
118
|
+
print
|
|
119
|
+
process
|
|
120
|
+
push
|
|
121
|
+
put
|
|
122
|
+
quit
|
|
123
|
+
read
|
|
124
|
+
receive
|
|
125
|
+
recv
|
|
126
|
+
redirect
|
|
127
|
+
refresh
|
|
128
|
+
register
|
|
129
|
+
release
|
|
130
|
+
reload
|
|
131
|
+
remove
|
|
132
|
+
render
|
|
133
|
+
rename
|
|
134
|
+
reset
|
|
135
|
+
resize
|
|
136
|
+
resolve
|
|
137
|
+
restore
|
|
138
|
+
return
|
|
139
|
+
reverse
|
|
140
|
+
rotate
|
|
141
|
+
run
|
|
142
|
+
save
|
|
143
|
+
scan
|
|
144
|
+
search
|
|
145
|
+
seek
|
|
146
|
+
select
|
|
147
|
+
send
|
|
148
|
+
set
|
|
149
|
+
setup
|
|
150
|
+
shift
|
|
151
|
+
show
|
|
152
|
+
shuffle
|
|
153
|
+
sign
|
|
154
|
+
skip
|
|
155
|
+
sort
|
|
156
|
+
split
|
|
157
|
+
start
|
|
158
|
+
step
|
|
159
|
+
stop
|
|
160
|
+
store
|
|
161
|
+
strip
|
|
162
|
+
sub
|
|
163
|
+
subtract
|
|
164
|
+
swap
|
|
165
|
+
switch
|
|
166
|
+
take
|
|
167
|
+
test
|
|
168
|
+
toggle
|
|
169
|
+
transform
|
|
170
|
+
translate
|
|
171
|
+
trim
|
|
172
|
+
truncate
|
|
173
|
+
try
|
|
174
|
+
unlock
|
|
175
|
+
unpack
|
|
176
|
+
update
|
|
177
|
+
use
|
|
178
|
+
validate
|
|
179
|
+
verify
|
|
180
|
+
wait
|
|
181
|
+
walk
|
|
182
|
+
write
|