Download the PHP package space48/magento2-code-quality without Composer

On this page you can find all versions of the php package space48/magento2-code-quality. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package magento2-code-quality

Space48 Code Quality tool

A module that helps to easily apply static code analysers to the project's code. It uses grumphp under the hood with a predefined set of rules based on Magento 2 coding standards but tuned to be less annoying!

Usage

Usage on a regular Space48 Warden based Magento 2 project:

After pulling and installing/updating project locally run following command to update local git hooks and install npm packages:

It will add precommit git hook, so on each commit linters will run for the files added to commit.

Git Pre-Commit

A commit will fail if linters found errors in your code, check the 'console' tab in 'Git' section of the PhpStorm for errors output by linters. Fix all errors and commit again.

Warning By default Autofix feature is turned ON. Once you try to commit, linters will automatically fix some errors. Double check changes after.

When fixing errors, to see predicted linters output you can instead of trying to commit again just run manually from console:

Usage on other projects

Run vendor/bin/grumphp git:init to add githook Grumphp will sniff your code on any git commit

Ignoring Rules

in the linters output you will see hints with rule names being violated. If for some reason you can not fix violated rule feel free to ignore it using Suppress Warning comment corresponding concrete linter type (see hints in output or google).

IMPORTANT! When ignoring a rule in the code always add a comment with the reason of why you had ignored it instead of fixing.

Finetuning

Rules can be tuned with parameters, excluded completely or rewritten on a Project Level using the ruleset.xml, phpmd.xml, .eslintrc, .stylelint files in the project's root folder and committing them to project's repo.

If you think everyone can benefit from your rules changes - feel free to create a PR.

CI Integration

To add Code Quality to Bitbucket pipelines as a mandatory step do following.

Edit Makefile

Add new command to makefile:

'111999' - is your starting commit hash

Configure bitbucket-pipelines.yml

Add new step to your build like this:

Check locally

To run linters as it would run on CI (from starting commit till HEAD):

Automatically fix some errors

Use any of this options:

Option 1: Set fixer/enabled and fixer/fix_by_default to true in grumphp.yml file

Option 2: Run command vendor/phpro/grumphp/bin/grumphp run with '--fix' option

Installation

Add Code Quality tool to the Magento Project:

Warning!

Eslisnt and Stylelint requires NodeJs v10 or higher.

Installation on a regular Space48 Warden based Magento 2 project:

On Magento versions earlier than 2.4 add following to 'require' section of project's composer.json:

1. Run following commands from project root:

Add the module

When it will ask for 'grumphp.yml' creation - answer no:

Copy files and install npm packages:

Add git precommit hook:

Create .git folder in warden:

(You can mount .git volume from host to inside container instead, but grumphp only requires empty .git folder, no much sense in syncronizing all .git/* files adding even more overhead for mutagen.)

Add configuration files to git:

2. Add following to project`s 'Makefile':

It contains following commands:

Update CQ_STARTING_COMMIT_HASH variable. Replace the sample a000z999 commit hash with the hash from the project where you want to start linting from. Files modified after the starting commit hash will be linted during project build and will fail the build on linter violations.

Update CQ_STARTING_COMMIT_DATE variable. Replace sample 01/01/2021 date with the date of the Starting Commit (specified at CQ_STARTING_COMMIT_HASH variable). This is required because CI uses shallow git clone.

Note: If using warden, commit still fails with SplFileInfo::openFile(/var/www/html/.git/COMMIT_EDITMSG): failed to open st ream: No such file or directory error: rename or revert to original git 'commit-msg' hook.

3. Commit to project`s repo.

Commit updated composer files, vendor folder, code-quality config files from the root and 'makefile' changes

Installation on any other Magento 2 project:

  1. add module space48/code-quality via Composer
  2. run vendor/space48/code-quality/script/install.sh script to copy necessary files and install npm packages
  3. in grumphp.yml remove configs marked as (remove on non warden environment)
  4. run vendor/bin/grumphp git:init to update precommit hooks

Configuration

Whitelist/exclude folders can be configured at {project_root}/grumphp.yml:

To turn off whole linter type (for example 'eslint') - remove or comment out corresponding 'task' section.

Linter rules can be finetuned on a project level by editing ruleset.xml, phpmd.xml, .eslintrc, .stylelint files. See Space48/code-quality/rulesets/ for examples.

Some rules can be overwritten on a class level. See rulesets/PhpMd/extra.xml for examples.

More info

For more info and for Configuration help refer to grumphp repo docs.


All versions of magento2-code-quality with dependencies

PHP Build Version
Package Version
Requires phpro/grumphp Version ^1.3
symfony/dom-crawler Version *
magento/magento-coding-standard Version *
phpmd/phpmd Version ^2
squizlabs/php_codesniffer Version >=2.9.2 <4.0.0
space48/grumphp-stylelint-task Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package space48/magento2-code-quality contains the following files

Loading the files please wait ....