{"id":19820011,"url":"https://github.com/mbund/cse2421-linter","last_synced_at":"2026-05-13T18:03:11.683Z","repository":{"id":216773796,"uuid":"742110276","full_name":"mbund/cse2421-linter","owner":"mbund","description":"Lint for some extra rules for C","archived":false,"fork":false,"pushed_at":"2024-01-13T06:03:07.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-11T08:28:45.324Z","etag":null,"topics":["lint","linter","parse","parser","rust","tree-sitter"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbund.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2024-01-11T19:29:38.000Z","updated_at":"2024-01-13T05:59:01.000Z","dependencies_parsed_at":"2024-01-13T18:01:01.978Z","dependency_job_id":"6d7cea1e-dfe4-4a55-a4a5-15c5e9f4494c","html_url":"https://github.com/mbund/cse2421-linter","commit_stats":null,"previous_names":["mbund/cse2331-linter","mbund/cse2421-linter"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbund%2Fcse2421-linter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbund%2Fcse2421-linter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbund%2Fcse2421-linter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbund%2Fcse2421-linter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbund","download_url":"https://codeload.github.com/mbund/cse2421-linter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241176617,"owners_count":19922732,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lint","linter","parse","parser","rust","tree-sitter"],"created_at":"2024-11-12T10:21:02.961Z","updated_at":"2026-05-13T18:03:06.632Z","avatar_url":"https://github.com/mbund.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSE 2421 Rule Linter\n\nLint for some extra rules for C\n\n- [x] No global variables\n- [x] Top level functions must have a comment explaining what they do\n- [x] 10 \"meaningful\" lines of code per function\n  - Declarations and comments do not count\n  - DEBUG blocks do not count\n  - If statements count (and else if)\n  - Else statemetns do not count\n  - Opening and closing curly brackets do not count\n- [ ] `DEBUG` macro\n  - A debug block is guarded by `#ifdef DEBUG` and `#endif`\n  - There can only be print messages starting with the function name or `ERROR: \u003cfunction name\u003e` (⚠ not implemented)\n  - No code may modify any variables (⚠ not implemented)\n- [x] Identifiers are all either `lower_snake_case` or `camelCase`\n- [x] Macros must be `UPPER_SNAKE_CASE`\n\n## Example\n\nTake the following C code (`example.c` in the repo) as an example:\n\n```c\n#include \u003cstdio.h\u003e\n\n#define pi 3.141592653589\n#define TAU (2 * pi)\n\nunsigned int globalOneThousand = 1000;\n\n// Do some math\ndouble calculate(unsigned long long x) {\n  unsigned long long final_value;\n\n  // make sure x is even\n  if (x % 2 == 0) {\n    final_value = x;\n  } else {\n    final_value = x + 1;\n  }\n\n  // multiply final value by 3/2\n  final_value = final_value / 2;\n  final_value = final_value * 3;\n\n  // round final value down to nearest 100\n  while (final_value % 100 != 0) {\n    final_value--;\n  }\n\n  // multiply by tau for some reason?\n  double actualFinalValue = final_value * TAU;\n\n#ifdef DEBUG\n  printf(\"The final value is %llu\\n\", final_value);\n#endif\n\n  printf(\"The actual final value is %f\\n\",\n    actualFinalValue);\n\n  return actualFinalValue;\n}\n\nint main() {\n  double value = calculate(37);\n  printf(\"The value is %f\\n\", value);\n\n  return 0;\n}\n```\n\nThen, the linter outputs the following :rocket:\n\n```\nexample.c:3:9 Macro is not SCREAMING_SNAKE_CASE `#define pi 3.141592653589`\nexample.c:6:1 Global variable `unsigned int globalOneThousand = 1000;`\nexample.c:6:14 Camel case identifier contributes to case inconsistency `globalOneThousand`\nexample.c:9:8 Function has more than 10 lines (11) `double calculate(unsigned long long x) {`\n  1) example.c:13:6 Counted if condition for 1 line `  if (x % 2 == 0) {`\n  2) example.c:14:5 Counted expression for 1 line `    final_value = x;`\n  3) example.c:16:5 Counted expression for 1 line `    final_value = x + 1;`\n  4) example.c:20:3 Counted expression for 1 line `  final_value = final_value / 2;`\n  5) example.c:21:3 Counted expression for 1 line `  final_value = final_value * 3;`\n  6) example.c:24:9 Counted while condition for 1 line `  while (final_value % 100 != 0) {`\n  7) example.c:25:5 Counted expression for 1 line `    final_value--;`\n  8) example.c:29:10 Counted definition for 1 line `  double actualFinalValue = final_value * TAU;`\n  9) example.c:35:3 Counted expression for 2 lines `  printf(\"The actual final value is %f\\n\",`\n  10) example.c:38:10 Counted return for 1 line `  return actualFinalValue;`\nexample.c:10:22 Snake case identifier contributes to case inconsistency `final_value`\nexample.c:29:10 Camel case identifier contributes to case inconsistency `actualFinalValue`\nexample.c:41:5 Missing comment directly above function `int main() {`\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbund%2Fcse2421-linter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbund%2Fcse2421-linter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbund%2Fcse2421-linter/lists"}