{"id":19359740,"url":"https://github.com/codacy/codacy-codesniffer","last_synced_at":"2025-04-23T11:32:49.365Z","repository":{"id":12734603,"uuid":"65012018","full_name":"codacy/codacy-codesniffer","owner":"codacy","description":"Codacy tool for PHP Codesniffer","archived":false,"fork":false,"pushed_at":"2025-04-16T21:12:30.000Z","size":1555,"stargazers_count":7,"open_issues_count":11,"forks_count":15,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-20T11:43:52.232Z","etag":null,"topics":["codacy","codesniffer","codesniffer-rules","docker","php","php-code-sniffer","php-codesniffer","review","scala"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codacy.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-05T10:56:36.000Z","updated_at":"2025-02-03T18:07:51.000Z","dependencies_parsed_at":"2023-02-17T11:45:20.014Z","dependency_job_id":"98120d75-6884-4da4-81d2-f586e439d7c9","html_url":"https://github.com/codacy/codacy-codesniffer","commit_stats":null,"previous_names":[],"tags_count":158,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codacy%2Fcodacy-codesniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codacy%2Fcodacy-codesniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codacy%2Fcodacy-codesniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codacy%2Fcodacy-codesniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codacy","download_url":"https://codeload.github.com/codacy/codacy-codesniffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250425548,"owners_count":21428578,"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":["codacy","codesniffer","codesniffer-rules","docker","php","php-code-sniffer","php-codesniffer","review","scala"],"created_at":"2024-11-10T07:15:59.391Z","updated_at":"2025-04-23T11:32:48.882Z","avatar_url":"https://github.com/codacy.png","language":"Scala","readme":"# Codacy PHP_CodeSniffer\n\nThis is the docker engine we use at Codacy to have [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) support.\nYou can also create a docker to integrate the tool and language of your choice!\nSee the [codacy-engine-scala-seed](https://github.com/codacy/codacy-engine-scala-seed) repository for more information.\n\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b695e76adcfa48749a8eaa33f2f2f626)](https://www.codacy.com/gh/codacy/codacy-codesniffer?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=codacy/codacy-codesniffer\u0026utm_campaign=Badge_Grade)\n[![Build Status](https://circleci.com/gh/codacy/codacy-codesniffer.svg?style=shield)](https://circleci.com/gh/codacy/codacy-codesniffer)\n\n## Usage\n\nYou can create the docker by doing:\n\n```bash\ndocker build -t codacy-codesniffer .\n```\n\nThe docker is ran with the following command:\n\n```bash\ndocker run -it -v $srcDir:/src \u003cDOCKER_NAME\u003e:\u003cDOCKER_VERSION\u003e\n```\n\n## Test\n\nWe use the [codacy-plugins-test](https://github.com/codacy/codacy-plugins-test) to test our external tools integration.\nYou can follow the instructions there to make sure your tool is working as expected.\n\n## Generating the documentation\n\nRequires `phpdoc`\n\n```bash\nwget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.4.3/phpDocumentor.phar\nsudo mv phpDocumentor.phar /usr/local/bin/phpdoc\nsudo chmod +x /usr/local/bin/phpdoc\n```\n\nUpdate the versions in `composer.json` and run\n\n```bash\nsbt \"doc-generator/runMain codacy.codesniffer.docsgen.GeneratorMain\"\n```\n\nThis will create updated `patterns.json`, `description.json` and the individual documentation Markdown files.\n\n## CodeSniffer configuration file\n\nPHP CodeSniffer can be configured by adding a `phpcs.xml` file to the source code.\n\nCurrently, the tool supports this configuration file except from one feature - setting installed_paths: `\u003cconfig name=\"installed_paths\" /\u003e`\n\n## Add new Codesniffer plugin\n\nTo add a new plugin to Codesniffer:\n\n1.  Add the plugin dependency to `require` inside `composer.json`. This depedency must be available on [Packagist](https://packagist.org/)\n\n2.  Add to `src/main/scala/codacy/codesniffer/docsgen/VersionsHelper.scala` the plugin version:\n\n    ```scala\n    lazy val newPlugin = properties(\"pluginNamespace/pluginName\").str.replace(\"^\",\"\")\n    ```\n\n3.  Implement the plugin documentation parser inside `src/main/scala/codacy/codesniffer/docsgen/parsers`. The parser must extend `DocsParser` and override the following:\n\n    | Name                                                                                                                                        | Description                                                                                     |\n    | ------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |\n    | `override val repositoryURL`                                                                                                                | Plugin's git repository                                                                         |\n    | `override val checkoutCommit`                                                                                                               | Commit related to the version on plugin's git repository (you can use the version tag for that) |\n    | `override val sniffRegex`                                                                                                                   | Regex to get all Sniffs implementation files                                                    |\n    | `override def patternIdPartsFor(relativizedFilePath: String): PatternIdParts`                                                               | Get the pattern id parts from pattern path                                                      |\n    | `override def descriptionWithDocs(rootDir: File, patternIdParts: PatternIdParts, patternFile: File): (Pattern.Description, Option[String])` | Get tuple with small and extended description for pattern                                       |\n\n\n    Example:\n\n    ```scala\n    class DrupalCoderDocsParser extends DocsParser {\n\n        override val repositoryURL = \"https://github.com/pfrenssen/coder.git\"\n\n        override val checkoutCommit: String = VersionsHelper.drupalCoder\n\n        override val sniffRegex: Regex = \"\"\".*coder_sniffer\\/(Drupal)\\/Sniffs\\/(.*?)\\/(.*?)Sniff.php\"\"\".r\n\n        override def patternIdPartsFor(relativizedFilePath: String): PatternIdParts = {\n            val sniffRegex(drupalCoderVersion, sniffType, patternName) = relativizedFilePath\n            PatternIdParts(drupalCoderVersion, sniffType, patternName)\n        }\n\n        override def descriptionWithDocs(rootDir: File,\n                                        patternIdParts: PatternIdParts,\n                                        patternFile: File): (Pattern.Description, Option[String]) = {\n            (description(patternIdParts, rootDir), this.parseExtendedDescription(\"Drupal\\\\Sniffs\", patternIdParts, rootDir))\n        }\n\n        private[this] def description(patternIdParts: PatternIdParts, rootDir: File): Pattern.Description = {\n            val caseRegexPattern = \"\"\"((?\u003c=\\p{Ll})\\p{Lu}|\\p{Lu}(?=\\p{Ll}))\"\"\".r\n            val patternName = caseRegexPattern.replaceAllIn(patternIdParts.patternName, \" $1\").trim\n            val sniffName = caseRegexPattern.replaceAllIn(patternIdParts.sniffType, \" $1\").trim\n            val title = Pattern.Title(s\"$sniffName: $patternName\")\n            val extended = this.parseDescription(\"Drupal\\\\Sniffs\", patternIdParts, rootDir)\n            Pattern.Description(patternIdParts.patternId, title, extended, None, None)\n        }\n\n    }\n    ```\n\n4.  Add the new parser to the list of parsers inside `src/main/scala/codacy/codesniffer/docsgen/Generator.scala`.\n\n    ```scala\n    private[this] val parsers: List[DocsParser] = List(new PHPCSDocsParser(), ...)\n    ```\n\n5.  [Generate the documentation](#generating-the-documentation)\n\n## What is Codacy?\n\n[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.\n\n### Among Codacy’s features\n\n-   Identify new Static Analysis issues\n-   Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)\n-   Auto-comments on Commits and Pull Requests\n-   Integrations with Slack, HipChat, Jira, YouTrack\n-   Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories\n\nCodacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.\n\nCodacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.\n\n### Free for Open Source\n\nCodacy is free for Open Source projects.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodacy%2Fcodacy-codesniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodacy%2Fcodacy-codesniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodacy%2Fcodacy-codesniffer/lists"}