Skip to content

Add Composer scripts for code sniffing and autofixing #218

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

Merged
merged 1 commit into from
May 7, 2021

Conversation

oliverklee
Copy link
Collaborator

There now are the following new Composer scripts:

  • ci: run all CI-related Composer scripts
  • ci:static run the static code analysis
  • ci:php:sniff run PHP_CodeSniffer
  • fix:php fix the autofixable PHP code warnings
  • fix:php:sniff fix the autofixable PHP_CodeSniffer warnings

For starters, we have a sniff that checks for the PSR-12 standard.
(The CI builds do not run this check as the files are not
PSR-12 compliant yet at this point.)

Comment on lines +9 to +11

<!-- The complete PSR-12 ruleset -->
<rule ref="PSR12">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be useful to add the PHPCompatibility sniffs to make sure that PHP 5.6 features are used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably will be a bit more work to get those to run with a PHIVE-based installation. Please let's do this in a separate PR. (I can do that.)

@oliverklee oliverklee force-pushed the feature/code-sniffer branch from 3bf9094 to 0730277 Compare May 3, 2021 17:13
.gitattributes Outdated
Comment on lines 5 to 6
/phive.xml
/phpcs.xml export-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to have these files in the root dir? I would like to keep the root dir as tidy as possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerning PHIVE: There is a second default location for the configuration file: .phive/phars.xml, and we could also move the tools from tools/ to .phive/ as well (like we do in the Emogrifer project).

We can also move the PHP_Codesniffer configuration to file and that reference the configuration ("code standard") file in the Composer commands, e.g., to config/phpcs.xml. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. Maybe phpunit.xml could also be moved to the config folder? And Doxyfile. Which reminds me: we should have a task that updates gh-pages after releases to publish https://sabberworm.github.io/PHP-CSS-Parser/.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also move the PHP_Codesniffer configuration to file and that reference the configuration ("code standard") file in the Composer commands, e.g., to config/phpcs.xml. What do you think?

A downside to that is that tools/editors will fail to discover the configuration files automatically.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move the PHIVE configuration file (and the PHAR symlinks) in this PR. We can take care of the other configuration files later then (in separate issues/PRs as needed).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved the PHARs and the PHIVE configuration file now and repushed.

@oliverklee oliverklee force-pushed the feature/code-sniffer branch from 0730277 to 652b940 Compare May 5, 2021 10:54
There now are the following new Composer scripts:

- `ci`: run all CI-related Composer scripts
- `ci:static` run the static code analysis
- `ci:php:sniff` run PHP_CodeSniffer
- `fix:php` fix the autofixable PHP code warnings
- `fix:php:sniff` fix the autofixable PHP_CodeSniffer warnings

For starters, we have a sniff that checks for the PSR-12 standard.
(The CI builds do not run this check as the files are not
PSR-12 compliant yet at this point.)
@oliverklee oliverklee force-pushed the feature/code-sniffer branch from 652b940 to 2eb96e1 Compare May 7, 2021 16:29
@oliverklee oliverklee requested a review from sabberworm May 7, 2021 16:30
@sabberworm sabberworm merged commit 4b2f5a3 into MyIntervals:master May 7, 2021
@oliverklee oliverklee deleted the feature/code-sniffer branch May 7, 2021 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants