@mytechtoday/augment-extensions 1.4.0 → 1.5.0

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 (307) hide show
  1. package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
  2. package/augment-extensions/coding-standards/c/LICENSE +22 -0
  3. package/augment-extensions/coding-standards/c/README.md +167 -0
  4. package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
  5. package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
  6. package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
  7. package/augment-extensions/coding-standards/c/config/schema.json +244 -0
  8. package/augment-extensions/coding-standards/c/docs/API.md +613 -0
  9. package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
  10. package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
  11. package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
  12. package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
  13. package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
  14. package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
  15. package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
  16. package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
  17. package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
  18. package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
  19. package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
  20. package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
  21. package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
  22. package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
  23. package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
  24. package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
  25. package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
  26. package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
  27. package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
  28. package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
  29. package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
  30. package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
  31. package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
  32. package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
  33. package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
  34. package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
  35. package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
  36. package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
  37. package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
  38. package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
  39. package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
  40. package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
  41. package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
  42. package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
  43. package/augment-extensions/coding-standards/c/module.json +149 -0
  44. package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
  45. package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
  46. package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
  47. package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
  48. package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
  49. package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
  50. package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
  51. package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
  52. package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
  53. package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
  54. package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
  55. package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
  56. package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
  57. package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
  58. package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
  59. package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
  60. package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
  61. package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
  62. package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
  63. package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
  64. package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
  65. package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
  66. package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
  67. package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
  68. package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
  69. package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
  70. package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
  71. package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
  72. package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
  73. package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
  74. package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
  75. package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
  76. package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
  77. package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
  78. package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
  79. package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
  80. package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
  81. package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
  82. package/augment-extensions/coding-standards/go/README.md +200 -0
  83. package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
  84. package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
  85. package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
  86. package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
  87. package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
  88. package/augment-extensions/coding-standards/go/config/schema.json +110 -0
  89. package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
  90. package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
  91. package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
  92. package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
  93. package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
  94. package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
  95. package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
  96. package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
  97. package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
  98. package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
  99. package/augment-extensions/coding-standards/go/module.json +139 -0
  100. package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
  101. package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
  102. package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
  103. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
  104. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
  105. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
  106. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
  107. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
  108. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
  109. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
  110. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
  111. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
  112. package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
  113. package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
  114. package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
  115. package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
  116. package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
  117. package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
  118. package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
  119. package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
  120. package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
  121. package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
  122. package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
  123. package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
  124. package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
  125. package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
  126. package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
  127. package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
  128. package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
  129. package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
  130. package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
  131. package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
  132. package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
  133. package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
  134. package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
  135. package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
  136. package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
  137. package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
  138. package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
  139. package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
  140. package/cli/dist/analysis/ast-parser.d.ts +47 -0
  141. package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
  142. package/cli/dist/analysis/ast-parser.js +161 -0
  143. package/cli/dist/analysis/ast-parser.js.map +1 -0
  144. package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
  145. package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
  146. package/cli/dist/analysis/complexity-analyzer.js +189 -0
  147. package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
  148. package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
  149. package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
  150. package/cli/dist/analysis/dependency-analyzer.js +237 -0
  151. package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
  152. package/cli/dist/analysis/index.d.ts +9 -0
  153. package/cli/dist/analysis/index.d.ts.map +1 -0
  154. package/cli/dist/analysis/index.js +25 -0
  155. package/cli/dist/analysis/index.js.map +1 -0
  156. package/cli/dist/analysis/security-scanner.d.ts +11 -0
  157. package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
  158. package/cli/dist/analysis/security-scanner.js +294 -0
  159. package/cli/dist/analysis/security-scanner.js.map +1 -0
  160. package/cli/dist/analysis/types.d.ts +151 -0
  161. package/cli/dist/analysis/types.d.ts.map +1 -0
  162. package/cli/dist/analysis/types.js +6 -0
  163. package/cli/dist/analysis/types.js.map +1 -0
  164. package/cli/dist/cli.js +24 -0
  165. package/cli/dist/cli.js.map +1 -1
  166. package/cli/dist/commands/code-analysis.d.ts +11 -0
  167. package/cli/dist/commands/code-analysis.d.ts.map +1 -0
  168. package/cli/dist/commands/code-analysis.js +412 -0
  169. package/cli/dist/commands/code-analysis.js.map +1 -0
  170. package/modules.md +99 -3
  171. package/package.json +14 -2
  172. package/cli/dist/commands/agent.d.ts +0 -37
  173. package/cli/dist/commands/agent.d.ts.map +0 -1
  174. package/cli/dist/commands/agent.js +0 -222
  175. package/cli/dist/commands/agent.js.map +0 -1
  176. package/cli/dist/commands/beads.d.ts +0 -64
  177. package/cli/dist/commands/beads.d.ts.map +0 -1
  178. package/cli/dist/commands/beads.js +0 -377
  179. package/cli/dist/commands/beads.js.map +0 -1
  180. package/cli/dist/commands/change.d.ts +0 -54
  181. package/cli/dist/commands/change.d.ts.map +0 -1
  182. package/cli/dist/commands/change.js +0 -243
  183. package/cli/dist/commands/change.js.map +0 -1
  184. package/cli/dist/commands/clean.d.ts +0 -15
  185. package/cli/dist/commands/clean.d.ts.map +0 -1
  186. package/cli/dist/commands/clean.js +0 -63
  187. package/cli/dist/commands/clean.js.map +0 -1
  188. package/cli/dist/commands/clone.d.ts +0 -15
  189. package/cli/dist/commands/clone.d.ts.map +0 -1
  190. package/cli/dist/commands/clone.js +0 -49
  191. package/cli/dist/commands/clone.js.map +0 -1
  192. package/cli/dist/commands/config.d.ts +0 -33
  193. package/cli/dist/commands/config.d.ts.map +0 -1
  194. package/cli/dist/commands/config.js +0 -166
  195. package/cli/dist/commands/config.js.map +0 -1
  196. package/cli/dist/commands/context.d.ts +0 -38
  197. package/cli/dist/commands/context.d.ts.map +0 -1
  198. package/cli/dist/commands/context.js +0 -205
  199. package/cli/dist/commands/context.js.map +0 -1
  200. package/cli/dist/commands/create.d.ts +0 -18
  201. package/cli/dist/commands/create.d.ts.map +0 -1
  202. package/cli/dist/commands/create.js +0 -178
  203. package/cli/dist/commands/create.js.map +0 -1
  204. package/cli/dist/commands/diff.d.ts +0 -19
  205. package/cli/dist/commands/diff.d.ts.map +0 -1
  206. package/cli/dist/commands/diff.js +0 -104
  207. package/cli/dist/commands/diff.js.map +0 -1
  208. package/cli/dist/commands/doctor.d.ts +0 -14
  209. package/cli/dist/commands/doctor.d.ts.map +0 -1
  210. package/cli/dist/commands/doctor.js +0 -62
  211. package/cli/dist/commands/doctor.js.map +0 -1
  212. package/cli/dist/commands/export.d.ts +0 -28
  213. package/cli/dist/commands/export.d.ts.map +0 -1
  214. package/cli/dist/commands/export.js +0 -135
  215. package/cli/dist/commands/export.js.map +0 -1
  216. package/cli/dist/commands/import.d.ts +0 -23
  217. package/cli/dist/commands/import.d.ts.map +0 -1
  218. package/cli/dist/commands/import.js +0 -118
  219. package/cli/dist/commands/import.js.map +0 -1
  220. package/cli/dist/commands/prompt.d.ts +0 -45
  221. package/cli/dist/commands/prompt.d.ts.map +0 -1
  222. package/cli/dist/commands/prompt.js +0 -223
  223. package/cli/dist/commands/prompt.js.map +0 -1
  224. package/cli/dist/commands/spec.d.ts +0 -57
  225. package/cli/dist/commands/spec.d.ts.map +0 -1
  226. package/cli/dist/commands/spec.js +0 -279
  227. package/cli/dist/commands/spec.js.map +0 -1
  228. package/cli/dist/commands/stats.d.ts +0 -18
  229. package/cli/dist/commands/stats.d.ts.map +0 -1
  230. package/cli/dist/commands/stats.js +0 -85
  231. package/cli/dist/commands/stats.js.map +0 -1
  232. package/cli/dist/commands/task.d.ts +0 -65
  233. package/cli/dist/commands/task.d.ts.map +0 -1
  234. package/cli/dist/commands/task.js +0 -282
  235. package/cli/dist/commands/task.js.map +0 -1
  236. package/cli/dist/commands/template.d.ts +0 -17
  237. package/cli/dist/commands/template.d.ts.map +0 -1
  238. package/cli/dist/commands/template.js +0 -55
  239. package/cli/dist/commands/template.js.map +0 -1
  240. package/cli/dist/utils/agent-config.d.ts +0 -129
  241. package/cli/dist/utils/agent-config.d.ts.map +0 -1
  242. package/cli/dist/utils/agent-config.js +0 -297
  243. package/cli/dist/utils/agent-config.js.map +0 -1
  244. package/cli/dist/utils/beads-graph.d.ts +0 -17
  245. package/cli/dist/utils/beads-graph.d.ts.map +0 -1
  246. package/cli/dist/utils/beads-graph.js +0 -150
  247. package/cli/dist/utils/beads-graph.js.map +0 -1
  248. package/cli/dist/utils/beads-integration.d.ts +0 -112
  249. package/cli/dist/utils/beads-integration.d.ts.map +0 -1
  250. package/cli/dist/utils/beads-integration.js +0 -312
  251. package/cli/dist/utils/beads-integration.js.map +0 -1
  252. package/cli/dist/utils/beads-reporter.d.ts +0 -17
  253. package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
  254. package/cli/dist/utils/beads-reporter.js +0 -160
  255. package/cli/dist/utils/beads-reporter.js.map +0 -1
  256. package/cli/dist/utils/cache-manager.d.ts +0 -55
  257. package/cli/dist/utils/cache-manager.d.ts.map +0 -1
  258. package/cli/dist/utils/cache-manager.js +0 -150
  259. package/cli/dist/utils/cache-manager.js.map +0 -1
  260. package/cli/dist/utils/change-manager.d.ts +0 -70
  261. package/cli/dist/utils/change-manager.d.ts.map +0 -1
  262. package/cli/dist/utils/change-manager.js +0 -412
  263. package/cli/dist/utils/change-manager.js.map +0 -1
  264. package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
  265. package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
  266. package/cli/dist/utils/config-manager-enhanced.js +0 -77
  267. package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
  268. package/cli/dist/utils/context-manager.d.ts +0 -96
  269. package/cli/dist/utils/context-manager.d.ts.map +0 -1
  270. package/cli/dist/utils/context-manager.js +0 -258
  271. package/cli/dist/utils/context-manager.js.map +0 -1
  272. package/cli/dist/utils/diff-engine.d.ts +0 -78
  273. package/cli/dist/utils/diff-engine.d.ts.map +0 -1
  274. package/cli/dist/utils/diff-engine.js +0 -233
  275. package/cli/dist/utils/diff-engine.js.map +0 -1
  276. package/cli/dist/utils/export-system.d.ts +0 -101
  277. package/cli/dist/utils/export-system.d.ts.map +0 -1
  278. package/cli/dist/utils/export-system.js +0 -289
  279. package/cli/dist/utils/export-system.js.map +0 -1
  280. package/cli/dist/utils/health-checker.d.ts +0 -66
  281. package/cli/dist/utils/health-checker.d.ts.map +0 -1
  282. package/cli/dist/utils/health-checker.js +0 -285
  283. package/cli/dist/utils/health-checker.js.map +0 -1
  284. package/cli/dist/utils/import-system.d.ts +0 -74
  285. package/cli/dist/utils/import-system.d.ts.map +0 -1
  286. package/cli/dist/utils/import-system.js +0 -317
  287. package/cli/dist/utils/import-system.js.map +0 -1
  288. package/cli/dist/utils/module-cloner.d.ts +0 -40
  289. package/cli/dist/utils/module-cloner.d.ts.map +0 -1
  290. package/cli/dist/utils/module-cloner.js +0 -136
  291. package/cli/dist/utils/module-cloner.js.map +0 -1
  292. package/cli/dist/utils/prompt-manager.d.ts +0 -90
  293. package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
  294. package/cli/dist/utils/prompt-manager.js +0 -302
  295. package/cli/dist/utils/prompt-manager.js.map +0 -1
  296. package/cli/dist/utils/spec-manager.d.ts +0 -65
  297. package/cli/dist/utils/spec-manager.d.ts.map +0 -1
  298. package/cli/dist/utils/spec-manager.js +0 -329
  299. package/cli/dist/utils/spec-manager.js.map +0 -1
  300. package/cli/dist/utils/stats-collector.d.ts +0 -74
  301. package/cli/dist/utils/stats-collector.d.ts.map +0 -1
  302. package/cli/dist/utils/stats-collector.js +0 -164
  303. package/cli/dist/utils/stats-collector.js.map +0 -1
  304. package/cli/dist/utils/template-engine.d.ts +0 -47
  305. package/cli/dist/utils/template-engine.d.ts.map +0 -1
  306. package/cli/dist/utils/template-engine.js +0 -204
  307. package/cli/dist/utils/template-engine.js.map +0 -1
@@ -0,0 +1,275 @@
1
+ # Rule: Const Correctness
2
+
3
+ ## Metadata
4
+ - **ID**: universal-const-correctness
5
+ - **Category**: universal
6
+ - **Severity**: WARNING
7
+ - **Standard**: C Standards, Best Practices
8
+ - **Version**: 1.0.0
9
+
10
+ ## Description
11
+ Use `const` qualifier for read-only data, const pointers, and const function parameters to prevent unintended modifications and enable compiler optimizations.
12
+
13
+ ## Rationale
14
+ Const correctness:
15
+ - Prevents accidental modifications of data
16
+ - Documents intent and contracts in code
17
+ - Enables compiler optimizations
18
+ - Catches bugs at compile time
19
+ - Improves code safety and maintainability
20
+
21
+ ## Applies To
22
+ - C Standards: c89, c99, c11, c17, c23
23
+ - Categories: all
24
+
25
+ ## Rule Details
26
+
27
+ ### 1. Const Function Parameters
28
+ - Use `const` for parameters that won't be modified
29
+ - Especially important for pointer parameters
30
+ - Helps prevent accidental modifications
31
+
32
+ ### 2. Const Pointers
33
+ - `const int*` - pointer to const int (can't modify data)
34
+ - `int* const` - const pointer to int (can't modify pointer)
35
+ - `const int* const` - const pointer to const int (can't modify either)
36
+
37
+ ### 3. Const Return Values
38
+ - Return `const` pointers for read-only data
39
+ - Prevents caller from modifying internal state
40
+
41
+ ### 4. Const Global/Static Data
42
+ - Use `const` for constants and lookup tables
43
+ - May be placed in read-only memory (ROM)
44
+
45
+ ## Examples
46
+
47
+ ### ✅ Good Example 1: Const Function Parameters
48
+
49
+ ```c
50
+ #include <string.h>
51
+
52
+ /**
53
+ * @brief Calculates the length of a string
54
+ * @param str String to measure (not modified)
55
+ * @return Length of the string
56
+ */
57
+ size_t string_length(const char* str) {
58
+ if (str == NULL) {
59
+ return 0;
60
+ }
61
+
62
+ size_t len = 0;
63
+ while (str[len] != '\0') {
64
+ len++;
65
+ }
66
+ return len;
67
+ }
68
+
69
+ /**
70
+ * @brief Copies a string to a buffer
71
+ * @param dest Destination buffer (modified)
72
+ * @param src Source string (not modified)
73
+ * @param size Size of destination buffer
74
+ */
75
+ void safe_string_copy(char* dest, const char* src, size_t size) {
76
+ if (dest == NULL || src == NULL || size == 0) {
77
+ return;
78
+ }
79
+
80
+ strncpy(dest, src, size - 1);
81
+ dest[size - 1] = '\0';
82
+ }
83
+ ```
84
+
85
+ ### ✅ Good Example 2: Const Pointers
86
+
87
+ ```c
88
+ /**
89
+ * @brief Finds the maximum value in an array
90
+ * @param arr Array to search (not modified)
91
+ * @param len Length of array
92
+ * @return Pointer to maximum element
93
+ */
94
+ const int* find_max(const int* arr, size_t len) {
95
+ if (arr == NULL || len == 0) {
96
+ return NULL;
97
+ }
98
+
99
+ const int* max = &arr[0];
100
+ for (size_t i = 1; i < len; i++) {
101
+ if (arr[i] > *max) {
102
+ max = &arr[i];
103
+ }
104
+ }
105
+ return max;
106
+ }
107
+
108
+ /**
109
+ * @brief Processes data with a fixed configuration
110
+ * @param config Configuration pointer (cannot be changed)
111
+ * @param data Data to process
112
+ */
113
+ void process_with_config(const Config* const config, Data* data) {
114
+ // config pointer cannot be changed
115
+ // config contents cannot be modified
116
+ // data can be modified
117
+
118
+ if (config->enable_feature_x) {
119
+ data->value *= config->multiplier;
120
+ }
121
+ }
122
+ ```
123
+
124
+ ### ✅ Good Example 3: Const Global Data
125
+
126
+ ```c
127
+ // Lookup table in read-only memory
128
+ const int FIBONACCI_TABLE[] = {
129
+ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144
130
+ };
131
+
132
+ const size_t FIBONACCI_TABLE_SIZE = sizeof(FIBONACCI_TABLE) / sizeof(FIBONACCI_TABLE[0]);
133
+
134
+ // Configuration constants
135
+ const char* const DEFAULT_CONFIG_PATH = "/etc/myapp/config.conf";
136
+ const int DEFAULT_PORT = 8080;
137
+ const double PI = 3.14159265359;
138
+ ```
139
+
140
+ ### ✅ Good Example 4: Const in Structs
141
+
142
+ ```c
143
+ typedef struct {
144
+ const char* name; // Pointer to const string
145
+ int id; // Mutable field
146
+ const int max_size; // Immutable field
147
+ } Config;
148
+
149
+ /**
150
+ * @brief Initializes a configuration
151
+ * @param cfg Configuration to initialize
152
+ * @param name Configuration name (must remain valid)
153
+ * @param id Configuration ID
154
+ */
155
+ void init_config(Config* cfg, const char* name, int id) {
156
+ // Cast away const for initialization (use carefully!)
157
+ *(int*)&cfg->max_size = 1024;
158
+ cfg->name = name;
159
+ cfg->id = id;
160
+ }
161
+ ```
162
+
163
+ ### ✅ Good Example 5: Const with Arrays
164
+
165
+ ```c
166
+ /**
167
+ * @brief Prints an array of integers
168
+ * @param arr Array to print (not modified)
169
+ * @param len Length of array
170
+ */
171
+ void print_array(const int arr[], size_t len) {
172
+ printf("[");
173
+ for (size_t i = 0; i < len; i++) {
174
+ printf("%d", arr[i]);
175
+ if (i < len - 1) {
176
+ printf(", ");
177
+ }
178
+ }
179
+ printf("]\n");
180
+ }
181
+ ```
182
+
183
+ ### ❌ Bad Example 1: Missing Const on Read-Only Parameters
184
+
185
+ ```c
186
+ // Should be const char*
187
+ int string_compare(char* s1, char* s2) {
188
+ // Function doesn't modify s1 or s2, but const is missing
189
+ return strcmp(s1, s2);
190
+ }
191
+ ```
192
+
193
+ ### ❌ Bad Example 2: Modifying Const Data
194
+
195
+ ```c
196
+ void bad_function(const int* data) {
197
+ // Compiler error: assignment of read-only location
198
+ *data = 42;
199
+ }
200
+ ```
201
+
202
+ ### ❌ Bad Example 3: Casting Away Const Unsafely
203
+
204
+ ```c
205
+ void dangerous_function(const char* str) {
206
+ // Dangerous: casting away const
207
+ char* mutable_str = (char*)str;
208
+ mutable_str[0] = 'X'; // Undefined behavior if str is in read-only memory!
209
+ }
210
+ ```
211
+
212
+ ### ❌ Bad Example 4: Non-Const Global Mutable Data
213
+
214
+ ```c
215
+ // Should be const
216
+ char* error_messages[] = {
217
+ "Success",
218
+ "Error",
219
+ "Warning"
220
+ };
221
+ ```
222
+
223
+ ## Const Pointer Cheat Sheet
224
+
225
+ ```c
226
+ int value = 42;
227
+
228
+ // Pointer to const int - can't modify value through pointer
229
+ const int* ptr1 = &value;
230
+ int const* ptr2 = &value; // Same as above
231
+ // *ptr1 = 10; // Error!
232
+ // ptr1 = &other; // OK
233
+
234
+ // Const pointer to int - can't modify pointer
235
+ int* const ptr3 = &value;
236
+ // *ptr3 = 10; // OK
237
+ // ptr3 = &other; // Error!
238
+
239
+ // Const pointer to const int - can't modify either
240
+ const int* const ptr4 = &value;
241
+ // *ptr4 = 10; // Error!
242
+ // ptr4 = &other; // Error!
243
+ ```
244
+
245
+ ## Reading Const Declarations
246
+
247
+ **Rule**: Read from right to left
248
+
249
+ ```c
250
+ const int* ptr; // ptr is a pointer to a const int
251
+ int const* ptr; // ptr is a pointer to a const int (same)
252
+ int* const ptr; // ptr is a const pointer to an int
253
+ const int* const ptr; // ptr is a const pointer to a const int
254
+ ```
255
+
256
+ ## Benefits
257
+
258
+ 1. **Compiler Optimization**: Const data can be placed in ROM or optimized
259
+ 2. **Thread Safety**: Const data is inherently thread-safe for reading
260
+ 3. **API Contracts**: Documents that function won't modify data
261
+ 4. **Bug Prevention**: Catches accidental modifications at compile time
262
+ 5. **Self-Documenting**: Makes code intent clear
263
+
264
+ ## References
265
+
266
+ - [C Standard - 6.7.3 Type qualifiers](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf)
267
+ - [CERT C - DCL00-C](https://wiki.sei.cmu.edu/confluence/display/c/DCL00-C.+Const-qualify+immutable+objects)
268
+ - [Const Correctness - C FAQ](https://c-faq.com/ansi/constmismatch.html)
269
+
270
+ ## Related Rules
271
+
272
+ - `universal-naming` - Const naming conventions (UPPER_CASE for const globals)
273
+ - `universal-memory-safety` - Const helps prevent buffer modifications
274
+ - `category-embedded` - Const data in ROM for embedded systems
275
+
@@ -0,0 +1,251 @@
1
+ # Rule: Documentation
2
+
3
+ ## Metadata
4
+ - **ID**: universal-documentation
5
+ - **Category**: universal
6
+ - **Severity**: WARNING
7
+ - **Standard**: Doxygen
8
+ - **Version**: 1.0.0
9
+
10
+ ## Description
11
+ Use Doxygen-style comments for all public APIs, including function documentation, parameter descriptions, return values, file headers, and inline comments for complex logic.
12
+
13
+ ## Rationale
14
+ Good documentation improves code maintainability, helps onboarding new developers, and serves as a contract for API usage. Doxygen-compatible comments enable automatic documentation generation.
15
+
16
+ ## Applies To
17
+ - C Standards: c89, c99, c11, c17, c23
18
+ - Categories: all
19
+
20
+ ## Rule Details
21
+
22
+ ### 1. Function Documentation
23
+ - Use `@brief` for short description
24
+ - Use `@param` for each parameter
25
+ - Use `@return` for return value description
26
+ - Use `@note` for important notes
27
+ - Use `@warning` for warnings
28
+
29
+ ### 2. File Headers
30
+ - Include file description
31
+ - Include author and date
32
+ - Include copyright/license if applicable
33
+
34
+ ### 3. Inline Comments
35
+ - Explain complex algorithms
36
+ - Document non-obvious behavior
37
+ - Clarify intent, not just what code does
38
+
39
+ ### 4. Struct/Enum Documentation
40
+ - Document each struct/enum
41
+ - Document important fields
42
+ - Explain usage patterns
43
+
44
+ ## Examples
45
+
46
+ ### ✅ Good Example 1: Function Documentation
47
+
48
+ ```c
49
+ /**
50
+ * @brief Calculates the factorial of a number
51
+ *
52
+ * This function computes n! (n factorial) using iterative approach.
53
+ * For large values of n, the result may overflow.
54
+ *
55
+ * @param n The number to calculate factorial for (must be >= 0)
56
+ * @return The factorial of n, or 0 if n is negative
57
+ *
58
+ * @note Maximum safe value depends on integer size
59
+ * @warning This function does not check for overflow
60
+ *
61
+ * @code
62
+ * unsigned long result = factorial(5); // Returns 120
63
+ * @endcode
64
+ */
65
+ unsigned long factorial(int n) {
66
+ if (n < 0) {
67
+ return 0;
68
+ }
69
+
70
+ unsigned long result = 1;
71
+ for (int i = 2; i <= n; i++) {
72
+ result *= i;
73
+ }
74
+ return result;
75
+ }
76
+ ```
77
+
78
+ ### ✅ Good Example 2: File Header
79
+
80
+ ```c
81
+ /**
82
+ * @file network_utils.c
83
+ * @brief Network utility functions for socket operations
84
+ *
85
+ * This module provides helper functions for common network operations
86
+ * including socket creation, connection management, and data transfer.
87
+ *
88
+ * @author John Doe
89
+ * @date 2024-01-15
90
+ * @version 1.0.0
91
+ *
92
+ * @copyright Copyright (c) 2024 Company Name
93
+ * Licensed under MIT License
94
+ */
95
+
96
+ #include "network_utils.h"
97
+ ```
98
+
99
+ ### ✅ Good Example 3: Struct Documentation
100
+
101
+ ```c
102
+ /**
103
+ * @brief Represents a user in the system
104
+ *
105
+ * This structure holds all user-related information including
106
+ * credentials, profile data, and access permissions.
107
+ */
108
+ typedef struct {
109
+ /** @brief Unique user identifier */
110
+ int user_id;
111
+
112
+ /** @brief Username (null-terminated, max 32 chars) */
113
+ char username[32];
114
+
115
+ /** @brief User's email address */
116
+ char email[64];
117
+
118
+ /** @brief Account creation timestamp (Unix epoch) */
119
+ time_t created_at;
120
+
121
+ /** @brief User permission level (0=guest, 1=user, 2=admin) */
122
+ int permission_level;
123
+ } User;
124
+ ```
125
+
126
+ ### ✅ Good Example 4: Enum Documentation
127
+
128
+ ```c
129
+ /**
130
+ * @brief Connection status codes
131
+ *
132
+ * Represents the current state of a network connection.
133
+ */
134
+ typedef enum {
135
+ /** @brief Connection not yet established */
136
+ CONN_STATUS_DISCONNECTED = 0,
137
+
138
+ /** @brief Connection in progress */
139
+ CONN_STATUS_CONNECTING = 1,
140
+
141
+ /** @brief Connection established and active */
142
+ CONN_STATUS_CONNECTED = 2,
143
+
144
+ /** @brief Connection failed or error occurred */
145
+ CONN_STATUS_ERROR = 3
146
+ } ConnectionStatus;
147
+ ```
148
+
149
+ ### ✅ Good Example 5: Complex Logic with Inline Comments
150
+
151
+ ```c
152
+ int process_packet(const uint8_t* data, size_t len) {
153
+ // Validate minimum packet size (header + checksum)
154
+ if (len < MIN_PACKET_SIZE) {
155
+ return -1;
156
+ }
157
+
158
+ // Extract header fields (network byte order)
159
+ uint16_t packet_type = ntohs(*(uint16_t*)data);
160
+ uint16_t payload_len = ntohs(*(uint16_t*)(data + 2));
161
+
162
+ // Verify payload length matches packet size
163
+ // Formula: header(4) + payload + checksum(2)
164
+ if (len != 4 + payload_len + 2) {
165
+ return -1;
166
+ }
167
+
168
+ // Calculate and verify checksum (last 2 bytes)
169
+ uint16_t expected_checksum = calculate_checksum(data, len - 2);
170
+ uint16_t actual_checksum = ntohs(*(uint16_t*)(data + len - 2));
171
+
172
+ if (expected_checksum != actual_checksum) {
173
+ return -1; // Checksum mismatch
174
+ }
175
+
176
+ return 0;
177
+ }
178
+ ```
179
+
180
+ ### ❌ Bad Example 1: No Documentation
181
+
182
+ ```c
183
+ int calc(int a, int b) {
184
+ return a * b + (a / b);
185
+ }
186
+ ```
187
+
188
+ ### ❌ Bad Example 2: Useless Comments
189
+
190
+ ```c
191
+ // Increment i
192
+ i++;
193
+
194
+ // Set x to 5
195
+ x = 5;
196
+
197
+ // Loop through array
198
+ for (int i = 0; i < n; i++) {
199
+ // Process element
200
+ process(arr[i]);
201
+ }
202
+ ```
203
+
204
+ ### ❌ Bad Example 3: Incomplete Documentation
205
+
206
+ ```c
207
+ /**
208
+ * Does something with data
209
+ */
210
+ int process_data(void* data, size_t len, int flags);
211
+ // Missing: what it does, param descriptions, return value
212
+ ```
213
+
214
+ ## Documentation Best Practices
215
+
216
+ ### DO:
217
+ - Document the "why", not just the "what"
218
+ - Keep documentation up-to-date with code changes
219
+ - Use examples for complex functions
220
+ - Document edge cases and limitations
221
+ - Explain non-obvious design decisions
222
+
223
+ ### DON'T:
224
+ - State the obvious (e.g., "// increment i" for `i++`)
225
+ - Leave outdated comments
226
+ - Document every single line
227
+ - Use comments to explain bad code (refactor instead)
228
+
229
+ ## Doxygen Tags Reference
230
+
231
+ | Tag | Purpose | Example |
232
+ |-----|---------|---------|
233
+ | `@brief` | Short description | `@brief Opens a file` |
234
+ | `@param` | Parameter description | `@param[in] fd File descriptor` |
235
+ | `@return` | Return value | `@return 0 on success, -1 on error` |
236
+ | `@note` | Important note | `@note Thread-safe` |
237
+ | `@warning` | Warning | `@warning Not reentrant` |
238
+ | `@see` | Cross-reference | `@see close_file()` |
239
+ | `@code/@endcode` | Code example | See examples above |
240
+
241
+ ## References
242
+
243
+ - [Doxygen Manual](https://www.doxygen.nl/manual/)
244
+ - [Linux Kernel Documentation](https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html)
245
+ - [GNU Coding Standards - Comments](https://www.gnu.org/prep/standards/standards.html#Comments)
246
+
247
+ ## Related Rules
248
+
249
+ - `universal-naming` - Clear names reduce need for comments
250
+ - `universal-error-handling` - Document error conditions
251
+