-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Touch up documentation for phpcs locally #1897
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
|
||
# Checking Code Style | ||
|
||
Before opening a pull request, you should check your code style. If you are using the [Vagrant](https://github.com/Islandora-Devops/claw-playbook), you can run `phpcs` within the Drupal installation directory (on the Vagrant, that is `/var/www/html/drupal`) or from within the `web` directory (`/var/www/html/drupal/web`) as follows: | ||
Before opening a pull request, you should check your code style using PHP_CodeSniffer (phpcs). We use the Drupal coding standards provided by [Drupal coder](https://www.drupal.org/project/coder). If you are using the [Ansible Playbook](https://github.com/Islandora-Devops/islandora-playbook), phpcs and Drupal Coder are installed and phpcs can be run as follows: | ||
|
||
* from within Drupal's root directory: `./vendor/bin/phpcs --standard=./vendor/drupal/coder/coder_sniffer/Drupal modules/contrib/my_module`, where `modules/contrib/my_module` is the relative or full path to the PHP file you want to check. | ||
* from within Drupal's `web` directory: `../vendor/bin/phpcs --standard=../vendor/drupal/coder/coder_sniffer/Drupal yourfile`, where `yourfile` is the relative or full path to the PHP file you want to check. | ||
* from within Drupal's root directory: `./vendor/bin/phpcs --standard=./vendor/drupal/coder/coder_sniffer/Drupal --ignore=*.md --extensions=php,module,inc,install,test,profile,theme,css,info web/modules/contrib/my_module` | ||
* from within Drupal's `web` directory: `../vendor/bin/phpcs --standard=../vendor/drupal/coder/coder_sniffer/Drupal --ignore=*.md --extensions=php,module,inc,install,test,profile,theme,css,info modules/contrib/my_module` | ||
|
||
In both cases: | ||
|
||
* `modules/contrib/my_module` is the relative or full path to the PHP file or directory you want to check. | ||
* the path to the coding standard file can be relative to where you are running it from, e.g. when in `web`: `--standard=../vendor/drupal/coder/coder_sniffer/Drupal` | ||
* you can specify a single file to check, or a directory path; in the latter case, all files in that directory will be checked. | ||
* the options `--ignore=*.md --extensions=php,module,inc,install,test,profile,theme,css,info` are what is used in our Travis CI environment (specified in the [Islandora CI](https://github.com/Islandora/islandora_ci/blob/main/travis_scripts.sh) shared module), which will cause your Pull Request to pass or fail its checks. | ||
|
||
Islandora 8 runs `phpcs` in its Travis continuous integration environment, and there, it specifies which files to ignore and which files to check. It is a good idea for developers to specify the same options when running `phpcs` locally, prior to opening a pull request. For example (running `phpcs` from the within Drupal's `web` directory), you should use the following `--ignore` and `--extensions` options: | ||
|
||
`../vendor/bin/phpcs --standard=../vendor/drupal/coder/coder_sniffer/Drupal --ignore=*.md --extensions=php,module,inc,install,test,profile,theme,css,info modules/contrib/my_module` | ||
If using a non-Ansible method of deployment, you may need to install phpcs and coder yourself, and the paths may vary. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a helpful bit of documentation if you're not using the ansible stuff |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also use the
DrupalPractice
libraryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elizoller I thought i knew what you meant but I'm not sure that I do!
In https://github.com/Islandora/islandora_ci/blob/main/travis_scripts.sh we run two commands:
phpcs --standard=Drupal
andphpcpd
. The second one looks to me to be a "copy paste detector".Looking into Drupal's docs on PHP CodeSniffer CommandLine Usage, they mention "Check Drupal Best Practices" with the example
phpcs --standard=DrupalPractice
.I don't see where we actually run this in our code checks. From my knowledge, what's in travis_scripts.sh in the islandora_ci library is the code check that applies to all our repos.
@dannylamb or @whikloj might also know?