{"id":17043430,"url":"https://github.com/leavez/lazywarningchecker","last_synced_at":"2026-02-28T07:06:27.172Z","repository":{"id":82216740,"uuid":"115335623","full_name":"leavez/LazyWarningChecker","owner":"leavez","description":"move \"Treat Warnings as Errors\" to commit time","archived":false,"fork":false,"pushed_at":"2018-01-08T11:31:17.000Z","size":51,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T09:45:08.938Z","etag":null,"topics":["treat-warnings","xcode"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leavez.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-25T12:17:08.000Z","updated_at":"2020-04-30T10:08:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"73b6a629-cdf4-4eed-949c-f34f68c02deb","html_url":"https://github.com/leavez/LazyWarningChecker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLazyWarningChecker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLazyWarningChecker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLazyWarningChecker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavez%2FLazyWarningChecker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leavez","download_url":"https://codeload.github.com/leavez/LazyWarningChecker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586231,"owners_count":21128997,"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":["treat-warnings","xcode"],"created_at":"2024-10-14T09:29:31.553Z","updated_at":"2026-02-28T07:06:22.153Z","avatar_url":"https://github.com/leavez.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LazyWarningChecker\n\nA configurable warning checking script for Xcode project.\n\n## What\nLazyWarningChecker is:\n- a script that print matched warnings from Xcode's build log.\n- a solution that moves the \"Treat Warnings as Errors\" feature to commit time, with configurable rules, without blocking debugging.\n- also a tool to generate a blame report of warnings.\n\n#### Why \"Treat Warnings as Errors\"?\n\nWarnings may grow to a huge level if we aren't disciplined enough. Too many warnings can swallow the newly generated ones when coding, which may have potential problems. \n\nFor example, an unimplemented method may cause a crash, but it can be easily avoided at by fix the compile warnings.\n\n#### Why another checking script?\n\n\"Treat Warnings as Errors\" is good, but very annoying when coding/debugging. The building could be interpreted by warnings very often, such as unused variables and unimplemented methods, which are common halfway code when developing. \n\nSo we move the checking to commit time, and get both strict warning checking and relaxed coding experience.\n\nFurthermore, the script provides a way to set checking rules, compared to prohibit all warning. You could only check several rules, or exclude some files.\n\nAlso, the script provides a functionality of generating a blame report for warning lines. \n\n## Usage \n### setup steps for moving \"Treat Warnings as Errors\" to commit time\n1. Copy the 2 script files to your project directory \n\n2. Add below to the build [Post-Action](https://i.stack.imgur.com/ft4Dw.png) of your scheme (remember to replace the path). And set `Provide build setting from` to your target. \n```bash\n# wait log file generated (3 seconds)\nfunction action() { sleep 3; python $SRCROOT/path/to/check_warning.py $BUILD_ROOT -o $SRCROOT/.warning_checker/last_result; python $SRCROOT/path/to/add_pre_commit_hook.py add $SRCROOT;  }\n\n# run in background to avoid blocking app launching\naction\u0026\n```\n\n3. Add `.warning_checker/last_result`  to .gitignore \n\nDone! Now you could get a commit time warning checking.\n\nNOTE: if a pre-commit hook already existed,  you should add the hook manually. The hook content could be got from `python add_pre_commit_hook.py raw`\n\nNOTE: Depend on how it works, the script cannot 100% guarantee excludes the warning line from committing. The checking result is only refreshed when build finished. So any change after building cannot be checked by this script. But it’s enough for most using cases.\n\n### generate blame report\n\n```shell\npython check_warning.py --blame path/to/issues_log # the path is the content of $BUILD_ROOT, you can the log_path in .warning_checker/last_result\n```\n\n### files\n`check_warning.py`  the main script for checking warnings\n\n`add_pre_commit_hook.py`  add pre-commit git hook to read the checking result.\nmore options in \"—help\"\n\n### configuration\nConfiguration file could be pass to check_warnings.py with `-c` option.\n\nThe configuration file is a JSON formatted text.\n```json\n{\n    \"show_non_pass_warning\": \"all\",\n    \"rules\": [\n        { \"type\" : \"flag\", \"content\": \"-Wunused-variable\" }\n    ],\n    \"exclusive_rules\": [\n        { \"type\" : \"regex\", \"content\": \"ABC.m\" }\n    ]\n}\n```\n\n- `show_non_pass_warning` : `all` means record all matched warnings. `first` means just return on the first match.\n- `rules`: the checking rules. No `rule` key in config means check all warnings. \n    - the rule object represented as `{ \"type\" : \"flag\", \"content\": \"-Wunused-variable\" } `\n    - type: `flag` means the match the [compiler's flag](https://clang.llvm.org/docs/DiagnosticsReference.html)\n    - type: `regex` means match the warning log with regular expression.  You could use it to match a specific file, or what you want. A common warning log looks like `/path/to/the/sourefile/ABCView.h:112:39: warning: auto property synthesis will not synthesize property 'description' because it is 'readwrite' but it will be synthesized 'readonly' via another property [-Wobjc-property-synthesis]`\n- `exclusive_rules` the rule to exclude warning logs.\n\n\n\n\n\n## How\n\n\nLazyWarningChecker scans the build logs generated by Xcode. All issues are logged as `xcactivitylog` file ( just a gzip file) in some path of the derivedData. \n\nThe script runs in the post-build action  (so we could run background task without block debugging.) and saves the checking result to file, which will be read by pre-commit git hook.\n\n\n## License\n\nLazyWarningChecker is available under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavez%2Flazywarningchecker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleavez%2Flazywarningchecker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavez%2Flazywarningchecker/lists"}