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.
Files changed (186) hide show
  1. jarbin_c_coding_style-2.0.0.dist-info/METADATA +150 -0
  2. jarbin_c_coding_style-2.0.0.dist-info/RECORD +186 -0
  3. jarbin_c_coding_style-2.0.0.dist-info/WHEEL +4 -0
  4. jarbin_c_coding_style-2.0.0.dist-info/entry_points.txt +2 -0
  5. jarbin_c_coding_style-2.0.0.dist-info/licenses/LICENSE +674 -0
  6. sources/__init__.py +0 -0
  7. sources/__main__.py +6 -0
  8. sources/analysis/__init__.py +0 -0
  9. sources/analysis/directives.py +258 -0
  10. sources/analysis/lexer.py +288 -0
  11. sources/analysis/parser.py +1754 -0
  12. sources/analysis/project.py +286 -0
  13. sources/analysis/source.py +326 -0
  14. sources/analysis/syntax.py +238 -0
  15. sources/analysis/tokens.py +116 -0
  16. sources/analysis/unit.py +700 -0
  17. sources/application.py +118 -0
  18. sources/build_info.json +6 -0
  19. sources/cli/__init__.py +0 -0
  20. sources/cli/arguments.py +507 -0
  21. sources/cli/completion.py +610 -0
  22. sources/cli/context.py +258 -0
  23. sources/cli/converters.py +204 -0
  24. sources/cli/help.py +162 -0
  25. sources/cli/parser.py +659 -0
  26. sources/configs/__init__.py +0 -0
  27. sources/configs/editor.py +207 -0
  28. sources/configs/ini.py +327 -0
  29. sources/configs/project.py +735 -0
  30. sources/configs/schema/__init__.py +0 -0
  31. sources/configs/schema/project.py +68 -0
  32. sources/constants.py +801 -0
  33. sources/diagnostics/__init__.py +0 -0
  34. sources/diagnostics/fingerprint.py +82 -0
  35. sources/diagnostics/model.py +146 -0
  36. sources/engine/__init__.py +0 -0
  37. sources/engine/api.py +355 -0
  38. sources/engine/examples.py +157 -0
  39. sources/engine/outcome.py +114 -0
  40. sources/engine/plan.py +440 -0
  41. sources/engine/runner.py +345 -0
  42. sources/engine/scanner.py +179 -0
  43. sources/enums.py +838 -0
  44. sources/errors/__init__.py +0 -0
  45. sources/errors/exceptions.py +727 -0
  46. sources/fixers/__init__.py +0 -0
  47. sources/fixers/base.py +209 -0
  48. sources/fixers/conflicts.py +129 -0
  49. sources/fixers/diff.py +73 -0
  50. sources/fixers/engine.py +434 -0
  51. sources/fixers/journal.py +290 -0
  52. sources/fixers/kinds.py +30 -0
  53. sources/fixers/layout.py +411 -0
  54. sources/fixers/model.py +151 -0
  55. sources/fixers/registry.py +54 -0
  56. sources/fixers/text.py +353 -0
  57. sources/fixers/verify.py +123 -0
  58. sources/fixers/writer.py +88 -0
  59. sources/integrations/__init__.py +0 -0
  60. sources/integrations/ci/__init__.py +0 -0
  61. sources/integrations/ci/github.py +183 -0
  62. sources/integrations/editors/__init__.py +0 -0
  63. sources/integrations/git/__init__.py +0 -0
  64. sources/integrations/git/repository.py +176 -0
  65. sources/integrations/update/__init__.py +0 -0
  66. sources/integrations/update/installers.py +529 -0
  67. sources/integrations/update/releases.py +397 -0
  68. sources/integrations/update/state.py +143 -0
  69. sources/outputs/__init__.py +0 -0
  70. sources/outputs/github/__init__.py +0 -0
  71. sources/outputs/github/renderer.py +135 -0
  72. sources/outputs/html/__init__.py +0 -0
  73. sources/outputs/html/renderer.py +694 -0
  74. sources/outputs/json/__init__.py +0 -0
  75. sources/outputs/json/renderer.py +154 -0
  76. sources/outputs/json/report.schema.json +121 -0
  77. sources/outputs/junit/__init__.py +0 -0
  78. sources/outputs/junit/renderer.py +151 -0
  79. sources/outputs/registry.py +135 -0
  80. sources/outputs/report.py +224 -0
  81. sources/outputs/sarif/__init__.py +0 -0
  82. sources/outputs/sarif/renderer.py +182 -0
  83. sources/outputs/terminal/__init__.py +0 -0
  84. sources/outputs/terminal/renderer.py +184 -0
  85. sources/outputs/terminal/style.py +159 -0
  86. sources/rules/__init__.py +0 -0
  87. sources/rules/arguments.py +362 -0
  88. sources/rules/catalog.py +227 -0
  89. sources/rules/categories/advanced/constant_pointers.ini +46 -0
  90. sources/rules/categories/advanced/line_break_at_end_of_file.ini +44 -0
  91. sources/rules/categories/advanced/static.ini +65 -0
  92. sources/rules/categories/advanced/typing.ini +47 -0
  93. sources/rules/categories/control_structures/conditional_branching.ini +89 -0
  94. sources/rules/categories/control_structures/goto.ini +45 -0
  95. sources/rules/categories/control_structures/ternary_operators.ini +57 -0
  96. sources/rules/categories/extensions/language_extensions.ini +71 -0
  97. sources/rules/categories/files_organization/contents_of_the_repository.ini +85 -0
  98. sources/rules/categories/files_organization/file_coherence.ini +166 -0
  99. sources/rules/categories/files_organization/file_extension.ini +68 -0
  100. sources/rules/categories/files_organization/fixtures/program +0 -0
  101. sources/rules/categories/files_organization/naming_files_and_folders.ini +74 -0
  102. sources/rules/categories/functions/coherence_of_functions.ini +45 -0
  103. sources/rules/categories/functions/comments_inside_a_function.ini +45 -0
  104. sources/rules/categories/functions/functions_without_parameters.ini +39 -0
  105. sources/rules/categories/functions/naming_functions.ini +79 -0
  106. sources/rules/categories/functions/number_of_columns.ini +61 -0
  107. sources/rules/categories/functions/number_of_lines.ini +70 -0
  108. sources/rules/categories/functions/number_of_parameters.ini +64 -0
  109. sources/rules/categories/functions/structures_as_parameters.ini +44 -0
  110. sources/rules/categories/global_scope/constant_values.ini +49 -0
  111. sources/rules/categories/global_scope/file_header.ini +92 -0
  112. sources/rules/categories/global_scope/global_variables.ini +53 -0
  113. sources/rules/categories/global_scope/include.ini +39 -0
  114. sources/rules/categories/global_scope/indentation_of_preprocessor.ini +62 -0
  115. sources/rules/categories/global_scope/inline_assembly.ini +43 -0
  116. sources/rules/categories/global_scope/leading_trailing_lines.ini +58 -0
  117. sources/rules/categories/global_scope/line_endings.ini +53 -0
  118. sources/rules/categories/global_scope/separation_of_functions.ini +61 -0
  119. sources/rules/categories/global_scope/trailing_spaces.ini +45 -0
  120. sources/rules/categories/header_files/content.ini +104 -0
  121. sources/rules/categories/header_files/include_guard.ini +47 -0
  122. sources/rules/categories/header_files/macros.ini +57 -0
  123. sources/rules/categories/layout_inside_a_function_scope/blank_lines.ini +71 -0
  124. sources/rules/categories/layout_inside_a_function_scope/code_line_content.ini +112 -0
  125. sources/rules/categories/layout_inside_a_function_scope/curly_brackets.ini +94 -0
  126. sources/rules/categories/layout_inside_a_function_scope/indentation.ini +96 -0
  127. sources/rules/categories/layout_inside_a_function_scope/spaces.ini +113 -0
  128. sources/rules/categories/layout_inside_a_function_scope/variable_declarations.ini +65 -0
  129. sources/rules/categories/variables_and_types/naming_identifiers.ini +74 -0
  130. sources/rules/categories/variables_and_types/pointers.ini +67 -0
  131. sources/rules/categories/variables_and_types/structures.ini +47 -0
  132. sources/rules/data/verbs.txt +182 -0
  133. sources/rules/definition.py +430 -0
  134. sources/rules/loader.py +925 -0
  135. sources/rules/paths.py +6 -0
  136. sources/rules/primitives/__init__.py +0 -0
  137. sources/rules/primitives/base.py +297 -0
  138. sources/rules/primitives/braces.py +211 -0
  139. sources/rules/primitives/directives.py +203 -0
  140. sources/rules/primitives/indentation.py +376 -0
  141. sources/rules/primitives/layout.py +199 -0
  142. sources/rules/primitives/naming.py +277 -0
  143. sources/rules/primitives/project.py +62 -0
  144. sources/rules/primitives/registry.py +49 -0
  145. sources/rules/primitives/repository.py +129 -0
  146. sources/rules/primitives/review.py +87 -0
  147. sources/rules/primitives/semantic.py +319 -0
  148. sources/rules/primitives/spacing.py +210 -0
  149. sources/rules/primitives/structure.py +586 -0
  150. sources/rules/primitives/syntax.py +200 -0
  151. sources/rules/primitives/text.py +408 -0
  152. sources/rules/primitives/tokens.py +84 -0
  153. sources/rules/template.py +138 -0
  154. sources/selftest/__init__.py +0 -0
  155. sources/selftest/cases.py +292 -0
  156. sources/services.py +90 -0
  157. sources/subcommands/__init__.py +0 -0
  158. sources/subcommands/base.py +45 -0
  159. sources/subcommands/check/__init__.py +0 -0
  160. sources/subcommands/check/command.py +45 -0
  161. sources/subcommands/check/fixing.py +224 -0
  162. sources/subcommands/check/handler.py +757 -0
  163. sources/subcommands/info/__init__.py +0 -0
  164. sources/subcommands/info/command.py +45 -0
  165. sources/subcommands/info/handler.py +527 -0
  166. sources/subcommands/registry.py +37 -0
  167. sources/subcommands/rule/__init__.py +0 -0
  168. sources/subcommands/rule/command.py +45 -0
  169. sources/subcommands/rule/handler.py +1067 -0
  170. sources/subcommands/rule/render.py +273 -0
  171. sources/subcommands/runner.py +124 -0
  172. sources/subcommands/test/__init__.py +0 -0
  173. sources/subcommands/test/command.py +45 -0
  174. sources/subcommands/test/handler.py +166 -0
  175. sources/subcommands/test/render.py +219 -0
  176. sources/subcommands/test/runner.py +430 -0
  177. sources/subcommands/update/__init__.py +0 -0
  178. sources/subcommands/update/command.py +45 -0
  179. sources/subcommands/update/handler.py +408 -0
  180. sources/utils/__init__.py +0 -0
  181. sources/utils/build_info.py +188 -0
  182. sources/utils/git.py +73 -0
  183. sources/utils/globs.py +98 -0
  184. sources/utils/logging.py +154 -0
  185. sources/utils/schema.py +77 -0
  186. sources/utils/versions.py +87 -0
@@ -0,0 +1,45 @@
1
+ [rule]
2
+ schema = 2
3
+ id = global_scope/trailing_spaces
4
+ title = Trailing spaces
5
+ summary = No trailing spaces are present at the end of a line.
6
+ applies_to = c, h
7
+ severity = minor
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-G7
13
+ version = 8
14
+ banana = full
15
+
16
+ [check:trailing]
17
+ kind = text_regex
18
+ on = line
19
+ pattern = [ \t]+$
20
+ message = {code}: trailing space(s)
21
+ fix = safe
22
+ fix.kind = strip_trailing_whitespace
23
+
24
+ [example:good_1]
25
+ kind = good
26
+
27
+ [example:good_1:file:ok.c]
28
+ code =
29
+ |int main(void)
30
+ |{
31
+ | return 0;
32
+ |}
33
+
34
+ [example:bad_1]
35
+ kind = bad
36
+ expect =
37
+ 1:15:trailing
38
+ 3:14:trailing
39
+
40
+ [example:bad_1:file:bad.c]
41
+ code =
42
+ |int main(void)\s\s
43
+ |{
44
+ | return 0;\t
45
+ |}
@@ -0,0 +1,104 @@
1
+ [rule]
2
+ schema = 2
3
+ id = header_files/content
4
+ title = Content
5
+ summary = Header files only contain function prototypes, type declarations, structure and enumeration declarations, global variable/constant declarations, macros and static inline functions; these elements are only found in header files. Conditional preprocessor directives should not be used in source files.
6
+ applies_to = c, h
7
+ severity = major
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-H1
13
+ version = 8
14
+ banana = partial
15
+ manual_part = Whether a header includes another header only because it needs it.
16
+
17
+ [check:header_items]
18
+ kind = top_level_items
19
+ where.file_kind = h
20
+ forbidden = function_definition
21
+ message = {code}: {value} in a header file
22
+
23
+ [check:source_items]
24
+ kind = top_level_items
25
+ where.file_kind = c
26
+ forbidden = prototype, typedef, record_declaration, extern_variable, macro, static_inline_function
27
+ message = {code}: {value} must only be found in header files
28
+
29
+ [check:conditional_in_source]
30
+ kind = top_level_items
31
+ where.file_kind = c
32
+ forbidden = conditional_directive
33
+ severity = info
34
+ message = {code}: conditional preprocessor directive in a source file
35
+
36
+ [check:needed_include]
37
+ kind = manual_review
38
+ target = file
39
+ where.file_kind = h
40
+ detection = manual
41
+ severity = info
42
+ question = Does {name} only include the headers it needs itself?
43
+
44
+ [example:good_1]
45
+ kind = good
46
+ expect = my.h:1:1:needed_include
47
+
48
+ [example:good_1:file:my.h]
49
+ code =
50
+ |#ifndef MY_H_
51
+ | #define MY_H_
52
+ | #include <stddef.h>
53
+ | #define MAX_SIZE 42
54
+ |typedef struct node_s {
55
+ | int value;
56
+ |} node_t;
57
+ |enum color { RED, GREEN };
58
+ |extern const int ANSWER;
59
+ |size_t get_length(char const *text);
60
+ |static inline int get_one(void)
61
+ |{
62
+ | return 1;
63
+ |}
64
+ |#endif
65
+
66
+ [example:good_1:file:my.c]
67
+ code =
68
+ |#include "my.h"
69
+ |
70
+ |const int ANSWER = 42;
71
+ |
72
+ |size_t get_length(char const *text)
73
+ |{
74
+ | return text[0];
75
+ |}
76
+
77
+ [example:bad_1]
78
+ kind = bad
79
+ expect =
80
+ bad.h:1:1:header_items
81
+ bad.h:1:1:needed_include
82
+ bad.c:1:1:source_items
83
+ bad.c:2:1:source_items
84
+ bad.c:3:1:source_items
85
+ bad.c:4:5:source_items
86
+ bad.c:5:1:conditional_in_source
87
+ bad.c:7:1:conditional_in_source
88
+
89
+ [example:bad_1:file:bad.h]
90
+ code =
91
+ |int get_one(void)
92
+ |{
93
+ | return 1;
94
+ |}
95
+
96
+ [example:bad_1:file:bad.c]
97
+ code =
98
+ |#define LIMIT 3
99
+ |typedef int number_t;
100
+ |struct point { int x; };
101
+ |int get_two(void);
102
+ |#ifdef DEBUG
103
+ |int debug = 1;
104
+ |#endif
@@ -0,0 +1,47 @@
1
+ [rule]
2
+ schema = 2
3
+ id = header_files/include_guard
4
+ title = Include guard
5
+ summary = Headers are protected from double inclusion by the #ifndef, #define and #endif preprocessor directives.
6
+ applies_to = h
7
+ severity = major
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-H2
13
+ version = 8
14
+ banana = full
15
+
16
+ [check:guard]
17
+ kind = include_guard
18
+ message = {code}: header not protected from double inclusion ({value})
19
+
20
+ [example:good_1]
21
+ kind = good
22
+
23
+ [example:good_1:file:my.h]
24
+ code =
25
+ |/* Header of my project. */
26
+ |#ifndef MY_H_
27
+ | #define MY_H_
28
+ |int get_one(void);
29
+ |#endif
30
+
31
+ [example:bad_1]
32
+ kind = bad
33
+ expect =
34
+ once.h:1:1:guard
35
+ late.h:1:1:guard
36
+
37
+ [example:bad_1:file:once.h]
38
+ code =
39
+ |#pragma once
40
+ |int get_one(void);
41
+
42
+ [example:bad_1:file:late.h]
43
+ code =
44
+ |int get_one(void);
45
+ |#ifndef LATE_H_
46
+ | #define LATE_H_
47
+ |#endif
@@ -0,0 +1,57 @@
1
+ [rule]
2
+ schema = 2
3
+ id = header_files/macros
4
+ title = Macros
5
+ summary = Macros match only one statement and fit on a single line; shortening a long expression is not a valid reason to use a macro.
6
+ applies_to = c, h
7
+ severity = major
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-H3
13
+ version = 8
14
+ banana = full
15
+
16
+ [check:single_line]
17
+ kind = directive
18
+ names = define
19
+ forbid_continuation = true
20
+ message = {code}: macro '{name}' does not fit on a single line
21
+
22
+ [check:single_statement]
23
+ kind = directive
24
+ names = define
25
+ body_forbid = ;
26
+ message = {code}: macro '{name}' matches more than one statement
27
+
28
+ [check:shortening]
29
+ kind = directive
30
+ names = define
31
+ require_literal_body = true
32
+ detection = heuristic
33
+ severity = info
34
+ message = {code}: is macro '{name}' only used to shorten an expression?
35
+
36
+ [example:good_1]
37
+ kind = good
38
+
39
+ [example:good_1:file:ok.h]
40
+ code =
41
+ |#define PI 3.14159265358979323846
42
+ |#define DELTA(a, b, c) ((b) * (b) - 4 * (a) * (c))
43
+ |#define NAME "jccs"
44
+
45
+ [example:bad_1]
46
+ kind = bad
47
+ expect =
48
+ 1:1:single_statement
49
+ 2:1:single_line
50
+ 4:1:shortening
51
+
52
+ [example:bad_1:file:bad.h]
53
+ code =
54
+ |#define PRINT_NEXT(num) {num++; printf("%d", num);}
55
+ |#define ERROR_MESSAGE "Multiline macros" \\
56
+ | " have to be avoided"
57
+ |#define WIN (data->object->scene->state->window)
@@ -0,0 +1,71 @@
1
+ [rule]
2
+ schema = 2
3
+ id = layout_inside_a_function_scope/blank_lines
4
+ title = Blank lines
5
+ summary = A blank line separates the variable declarations from the remainder of the function; no other blank line is present in the function.
6
+ applies_to = c, h
7
+ severity = minor
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-L6
13
+ version = 8
14
+ banana = full
15
+
16
+ [check:after_declarations]
17
+ kind = blank_lines
18
+ region = after:declarations
19
+ exact = 1
20
+ message = {code}: {value} blank line(s) after the declarations (expected {limit})
21
+ fix = safe
22
+ fix.kind = blank_after_declarations
23
+
24
+ [check:other_blank_line]
25
+ kind = blank_lines
26
+ region = function_body
27
+ message = {code}: blank line inside the function
28
+ fix = safe
29
+ fix.kind = remove_blank_line
30
+
31
+ [example:good_1]
32
+ kind = good
33
+
34
+ [example:good_1:file:ok.c]
35
+ code =
36
+ |int sys_open(char const *path)
37
+ |{
38
+ | int fd = thread_reserve_fd();
39
+ | struct filehandler *fhandler = NULL;
40
+ |
41
+ | if (fd < 0) {
42
+ | return -1;
43
+ | }
44
+ | return fd;
45
+ |}
46
+ |
47
+ |int get_zero(void)
48
+ |{
49
+ | return 0;
50
+ |}
51
+
52
+ [example:bad_1]
53
+ kind = bad
54
+ expect =
55
+ 5:5:after_declarations
56
+ 10:1:other_blank_line
57
+
58
+ [example:bad_1:file:bad.c]
59
+ code =
60
+ |int sys_open(char const *path)
61
+ |{
62
+ | int fd = thread_reserve_fd();
63
+ | struct filehandler *fhandler = NULL;
64
+ | if (fs_open(path, &fhandler)) {
65
+ | thread_free_fd(fd);
66
+ | return -1;
67
+ | }
68
+ | thread_set_fd_handler(fd, fhandler);
69
+ |
70
+ | return fd;
71
+ |}
@@ -0,0 +1,112 @@
1
+ [rule]
2
+ schema = 2
3
+ id = layout_inside_a_function_scope/code_line_content
4
+ title = Code line content
5
+ summary = A line corresponds to only one statement; the for loop allows one statement in each of its three parts.
6
+ applies_to = c, h
7
+ severity = major
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-L1
13
+ version = 8
14
+ banana = partial
15
+ manual_part = Other ways to blend several statements into one.
16
+
17
+ [check:several_statements]
18
+ kind = node_forbid
19
+ node = expression_statement, return_statement, break_statement, continue_statement, goto_statement, declaration, type_definition, if_statement, for_statement, while_statement, do_statement, switch_statement, compound_statement
20
+ pattern.fields = shares_line_with_previous=true
21
+ message = {code}: several statements on the same line
22
+
23
+ [check:several_assignments]
24
+ kind = node_forbid
25
+ node = assignment_expression
26
+ pattern.parent = assignment_expression, init_declarator
27
+ report = once_per_line
28
+ message = {code}: several assignments on the same line
29
+
30
+ [check:assignment_in_condition]
31
+ kind = node_forbid
32
+ node = assignment_expression
33
+ pattern.ancestor = condition
34
+ message = {code}: assignment in a control structure expression
35
+
36
+ [check:assignment_in_expression]
37
+ kind = node_forbid
38
+ node = assignment_expression
39
+ pattern.not_parent = assignment_expression, init_declarator
40
+ pattern.not_ancestor = condition
41
+ pattern.fields = value_used=true
42
+ message = {code}: assignment inside another statement
43
+
44
+ [check:condition_and_statement]
45
+ kind = node_forbid
46
+ node = if_statement, while_statement, for_statement, switch_statement
47
+ pattern.fields = body_on_header_line=true
48
+ message = {code}: a condition and a statement on the same line
49
+
50
+ [check:for_part]
51
+ kind = node_forbid
52
+ node = comma_expression
53
+ pattern.parent = for_init, for_update
54
+ message = {code}: more than one statement in a part of a for loop
55
+
56
+ [check:side_effect]
57
+ kind = node_forbid
58
+ node = update_expression
59
+ pattern.fields = value_used=true
60
+ message = {code}: increment or decrement inside another statement
61
+
62
+ [check:logic_statement]
63
+ kind = node_forbid
64
+ node = logical_expression
65
+ pattern.parent = expression_statement
66
+ message = {code}: logical operator used to blend several statements
67
+
68
+ [example:good_1]
69
+ kind = good
70
+
71
+ [example:good_1:file:ok.c]
72
+ code =
73
+ |int fill(char *str, int *ptr)
74
+ |{
75
+ | int a = 0;
76
+ |
77
+ | a++;
78
+ | if (ptr != NULL)
79
+ | a = 1;
80
+ | for (int i = 0; i < 42; i++)
81
+ | str[i] = 'A';
82
+ | return my_strlen(str);
83
+ |}
84
+
85
+ [example:bad_1]
86
+ kind = bad
87
+ expect =
88
+ 5:9:several_assignments
89
+ 6:10:several_statements
90
+ 7:10:assignment_in_condition
91
+ 8:5:condition_and_statement
92
+ 9:9:side_effect
93
+ 10:25:for_part
94
+ 11:5:logic_statement
95
+ 12:18:several_assignments
96
+
97
+ [example:bad_1:file:bad.c]
98
+ code =
99
+ |void fill(char *str, int *ptr)
100
+ |{
101
+ | int a;
102
+ |
103
+ | a = b = c = 0;
104
+ | a++; b++;
105
+ | if ((ptr = malloc(42)) != NULL)
106
+ | if (cond) return (ptr);
107
+ | str[i++] = 'A';
108
+ | for (i = 0; i < 42; i++, j--)
109
+ | ((a != c) || (b != c)) && printf("Hello, world!\\n");
110
+ | for (int i = j = 0; i < 42; i++)
111
+ | a--;
112
+ |}
@@ -0,0 +1,94 @@
1
+ [rule]
2
+ schema = 2
3
+ id = layout_inside_a_function_scope/curly_brackets
4
+ title = Curly brackets
5
+ summary = Opening curly brackets are at the end of the line, after the content they precede, except for function definitions where they are alone on their line. Closing curly brackets are alone on their line, except for else / else if / do while, enum declarations and structure declarations. It also applies outside functions and in header files.
6
+ applies_to = c, h
7
+ severity = minor
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-L4
13
+ version = 8
14
+ banana = full
15
+
16
+ [check:opening]
17
+ kind = brace_placement
18
+ check_close = false
19
+ message = {code}: {value}
20
+ fix = safe
21
+ fix.kind = place_braces
22
+
23
+ [check:closing]
24
+ kind = brace_placement
25
+ check_open = false
26
+ message = {code}: {value}
27
+ fix = safe
28
+ fix.kind = place_braces
29
+
30
+ [example:good_1]
31
+ kind = good
32
+
33
+ [example:good_1:file:ok.c]
34
+ code =
35
+ |struct dummy {
36
+ | int var;
37
+ |};
38
+ |
39
+ |int print_env(void)
40
+ |{
41
+ | while (cond) {
42
+ | do_something();
43
+ | }
44
+ | if (cond) {
45
+ | do_one();
46
+ | } else {
47
+ | do_two();
48
+ | }
49
+ | do {
50
+ | do_three();
51
+ | } while (cond);
52
+ | if (cond)
53
+ | return ptr;
54
+ | return 0;
55
+ |}
56
+
57
+ [example:bad_1]
58
+ kind = bad
59
+ expect =
60
+ 1:21:opening
61
+ 3:5:opening
62
+ 3:17:closing
63
+ 5:5:opening
64
+ 11:5:closing
65
+ 19:22:opening
66
+ 23:1:opening
67
+
68
+ [example:bad_1:file:bad.c]
69
+ code =
70
+ |int print_env(void) {
71
+ | if (cond)
72
+ | {return ptr;}
73
+ | if (cond)
74
+ | {
75
+ | do_one();
76
+ | } else {
77
+ | do_two();
78
+ | }
79
+ | if (cond) {
80
+ | }
81
+ | else {
82
+ | }
83
+ |}
84
+ |
85
+ |
86
+ |
87
+ |
88
+ |int print_path(void) {
89
+ | return 0;
90
+ |}
91
+ |struct dummy
92
+ |{
93
+ | int var;
94
+ |};
@@ -0,0 +1,96 @@
1
+ [rule]
2
+ schema = 2
3
+ id = layout_inside_a_function_scope/indentation
4
+ title = Indentation
5
+ summary = Each indentation level is 4 spaces, no tabulation is used for indentation, and entering a new scope increments the level. Block comment bodies are freely indented with spaces.
6
+ applies_to = c, h
7
+ severity = minor
8
+ detection = automatic
9
+ status = stable
10
+
11
+ [epitech]
12
+ ref = C-L2
13
+ version = 8
14
+ banana = partial
15
+ manual_part = Exact level of every line (continuation lines, switch labels).
16
+
17
+ [argument:indent_unit]
18
+ type = int
19
+ default = 4
20
+ min = 1
21
+ description = Number of spaces per indentation level.
22
+
23
+ [check:tabulation]
24
+ kind = indentation
25
+ mode = tabs
26
+ message = {code}: tabulation used for indentation
27
+ fix = safe
28
+ fix.kind = indent_with_spaces
29
+
30
+ [check:unit]
31
+ kind = indentation
32
+ mode = multiple_of
33
+ unit = @indent_unit
34
+ message = {code}: indentation of {value} space(s) is not a multiple of {limit}
35
+ fix = safe
36
+ fix.kind = round_indentation
37
+
38
+ [check:level]
39
+ kind = indentation
40
+ mode = block
41
+ unit = @indent_unit
42
+ detection = heuristic
43
+ severity = info
44
+ message = {code}: indentation of {value} space(s), expected {limit}
45
+
46
+ [example:good_1]
47
+ kind = good
48
+
49
+ [example:good_1:file:ok.c]
50
+ code =
51
+ |int main(void)
52
+ |{
53
+ | char letter = 'H';
54
+ | int number = 14;
55
+ |
56
+ | if (letter == 'H') {
57
+ | my_putchar('U');
58
+ | } else if (letter == 'G') {
59
+ | if (number != 10)
60
+ | my_putchar('O');
61
+ | else {
62
+ | my_putnbr(97);
63
+ | }
64
+ | }
65
+ | while (my_function_with_a_long_name(
66
+ | letter, number)) {
67
+ | my_putchar('A');
68
+ | }
69
+ |}
70
+ |
71
+ |/**
72
+ | * @brief Something
73
+ | */
74
+ |void *something(const char *path);
75
+
76
+ [example:bad_1]
77
+ kind = bad
78
+ expect =
79
+ 3:1:level
80
+ 6:1:level
81
+ 8:1:tabulation
82
+ 9:1:unit
83
+ 9:1:level
84
+
85
+ [example:bad_1:file:bad.c]
86
+ code =
87
+ |int main(void)
88
+ |{
89
+ |int i;
90
+ |
91
+ | if (true) {
92
+ | return (0);
93
+ | }
94
+ |\tmy_putchar('a');
95
+ | my_putchar('b');
96
+ |}