{"id":17984132,"url":"https://github.com/bcrowe/cakephp-codesniffer-plugin","last_synced_at":"2025-08-01T01:03:04.592Z","repository":{"id":11169666,"uuid":"13544204","full_name":"bcrowe/cakephp-codesniffer-plugin","owner":"bcrowe","description":"CakePHP CodeSniffer plugin - for finding and auto-correcting coding standard issues.","archived":false,"fork":false,"pushed_at":"2013-10-16T00:52:08.000Z","size":1133,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T13:41:46.241Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcrowe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-10-13T18:14:52.000Z","updated_at":"2021-11-02T12:11:45.000Z","dependencies_parsed_at":"2022-08-30T20:50:59.664Z","dependency_job_id":null,"html_url":"https://github.com/bcrowe/cakephp-codesniffer-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-codesniffer-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-codesniffer-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-codesniffer-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-codesniffer-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcrowe","download_url":"https://codeload.github.com/bcrowe/cakephp-codesniffer-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247107827,"owners_count":20884797,"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":[],"created_at":"2024-10-29T18:19:36.873Z","updated_at":"2025-04-04T02:14:22.675Z","avatar_url":"https://github.com/bcrowe.png","language":"PHP","readme":"# CakePHP CodeSniffer Plugin\n\nAuthor: Mark Scherer\n\nLicense: MIT\n\nThe plugin provides a quick way to run your (default) sniffer rules on your app - or part (Plugin for example) of it.\nIt comes with good default settings for Cake apps and works out of the box as self-contained system.\n\nBy default it\n- ignores webroot and Vendor folders (in app or plugin)\n- creates a log file in TMP for larger error reports where the console screen can't hold that much information)\n- NEW: Can now also auto-correct most standard CS issues using the phpcs-fixer branch.\n\nIt is also quite helpful when creating new sniffer rules (using tokenizer command).\n\n## Requirements\n\nCakePHP 2.x\n\nThis is a self-contained plugin shipped with everything including phpcs and sniffs.\nDrag and drop it. Run it. Enjoy.\n\n## How to use\n\n1. Download the plugin and place it at `APP/Plugin/CodeSniffer` (or ROOT/plugins/ folder).\n\n   ```bash\n   cd APP/Plugin\n   git clone git://github.com/dereuromark/cakephp-codesniffer.git CodeSniffer\n   ```\n\n2. Load the plugin by adding this line to the bottom of your app's `Config/bootstrap.php`:\n\n   ```php\n   CakePlugin::load('CodeSniffer'); // or just CakePlugin::loadAll();\n   ```\n\n3. That's all! CodeSniffer is ready for use.\n\n   ```bash\n   cake CodeSniffer.CodeSniffer run [path]\n   ```\n\nIf you do not provide a path, it will automatically run the sniffer for your APP path.\n\nYou can also quickly sniff one of your plugins:\n\n\tcake CodeSniffer.CodeSniffer run -p Tools\n\nAnd by providing a path, as well, it will use it as sub path of your plugin:\n\n\tcake CodeSniffer.CodeSniffer run Model -p Tools\n\nNote that it will also create a full debug log file in your TMP folder. This is useful if there are a lot\nof errors and warnings.\n\nIf you want to display a list of available standards, use the \"standards\" command:\n\n\tcake CodeSniffer.Codesniffer standards\n\nYou can also check only a specific sniff:\n\n\tcake CodeSniffer.CodeSniffer run /folder/to/check --standard=MyCakePHP\n\t\t--sniffs=MyCakePHP.ControlStructures.ReturnEarly\n\nNEW: Upgrading the vendor phpcs package to \"phpcs-fixer\" branch, you can now leverage auto-correction\nfor some found errors using `--fix` or `-f`:\n\n\tcake CodeSniffer.Codesniffer run -f\n\nIt will also display a diff on old made changes afterwards.\nUsing the APP itself, a relative path inside the APP or `-p PluginName` it will by default skip any \"Vendor\"\nand \"webroot\" folders found. Using an absolute custom path it will not skip anything:\n\n\tcake CodeSniffer.Codesniffer run /folder/to/check -f\n\n### Settings/Options\n\nBy default it uses the CakePHP rules.\nYou can overwrite the default at runtime or globally using your APP configs:\n\n\t// Use our own standards \"MyCakePHP\" as default\n\tConfigure::write('CodeSniffer.standard', 'MyCakePHP');\n\n\t// A \"Custom\" standard that is somewhere else on your file system\n\tConfigure::write('CodeSniffer.standard', '/absolute/path/to/Custom');\n\n### Tokenizer\n\nYou can use the tokenizer command to debug your PHP files. This can be very useful when writing\nyour own rules. You can output just the token name list, but it is usually better to use the verbose\noutput:\n\n\tcake CodeSniffer.Codesniffer tokenize /path/to/file.ext -v\n\nThis will create a file `/path/to/file.ext.token` with all token names added in comment lines.\n\n### MyCakePHP improvements (optional)\n\n* Detect Yoda conditions.\n* Added IsNull sniff\n* Added Type casting sniff\n* Added @return doc block sniff\n* Added Ternary (incl. short ternary) sniff\n* ReturnEarly sniff to detect if a return statement is followed by an ELSE block.\n* Doc blocks / comments on correct indentation level (as their subsequent code).\n* Line endings on Windows are allowed to be \\r\\n (default for GIT on Windows for example).\n* Make Squiz sniff not falsely report whitespace issues in Windows.\n\nFor details see the ruleset.xml in the `Standards` dir.\n\nMost of those added sniffs also have auto-correction included. Use it :)\n\nNote: The \"correct\" indentation is APP and plugin specific for me. This is the only exception from the official CakePHP\nstandards and applies to all my (non core) code.\nYou are free to stick to the official version using the \"CakePHP\" standard!\n\n### MyCakePHPCore improvements (optional)\n\n* Line endings on Windows are allowed to be \\r\\n (default for GIT on Windows for example)\n* Detect Yoda conditions.\n\n## TODOS\n\nInstalling via composer or some more generic approach? This would avoid the hardwiring of PHPCS and the standards\nin this plugin.\n\nAlso: The main goal is to push forward automated code correction using the CodeFixer.\nUsing the same rules to \"find\" violations we should also be able to \"fix\" them right away in almost all cases.\n\nLast but not least there is also some more work to be done on the SmellDetector and other tools.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcrowe%2Fcakephp-codesniffer-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcrowe%2Fcakephp-codesniffer-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcrowe%2Fcakephp-codesniffer-plugin/lists"}