2018-07-10 18:59:52 +00:00
|
|
|
.. include:: /_includes/all.rst
|
2019-03-07 15:35:54 +00:00
|
|
|
.. include:: /_includes/snippets/__ANNOUNCEMENTS__.rst
|
2018-07-10 18:59:52 +00:00
|
|
|
|
2018-07-03 13:47:58 +00:00
|
|
|
.. _source_code_analysis:
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
********************
|
2018-07-03 13:47:58 +00:00
|
|
|
Source Code Analysis
|
2018-03-25 21:40:28 +00:00
|
|
|
********************
|
|
|
|
|
|
|
|
This tutorial gives you a general overview how to do static code analysis from within the PHP
|
|
|
|
container.
|
|
|
|
|
|
|
|
.. seealso::
|
2018-06-03 18:45:01 +00:00
|
|
|
* :ref:`available_tools`
|
2018-07-03 13:47:58 +00:00
|
|
|
* :ref:`work_inside_the_php_container`
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
.. contents:: :local:
|
|
|
|
|
|
|
|
|
|
|
|
Awesome-ci
|
|
|
|
==========
|
|
|
|
|
|
|
|
Awesome-ci is a collection of tools for analysing your
|
|
|
|
workspace and its files. You can for example check for:
|
|
|
|
|
|
|
|
* git conflicts
|
|
|
|
* git ignored files that have not been removed from the git index
|
|
|
|
* trailing spaces and newlines
|
|
|
|
* non-utf8 files or utf8 files with bom
|
|
|
|
* windows line feeds
|
|
|
|
* null-byte characters
|
|
|
|
* empty files
|
|
|
|
* syntax errors for various languages
|
|
|
|
* inline css or js code
|
|
|
|
* customized regex
|
|
|
|
|
|
|
|
Some of the bundled tools even allow for automatic fixing.
|
|
|
|
|
2018-07-10 18:59:52 +00:00
|
|
|
.. seealso:: |ext_lnk_tool_awesome_ci|
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 1. Enter your PHP container
|
|
|
|
host> ./bash
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 2. Go to your project folder
|
|
|
|
devilbox@php-7.0.20 $ cd /shared/httpd/my-project
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 3. Run the tools
|
|
|
|
devilbox@php-7.0.20 $ git-conflicts --path=.
|
|
|
|
devilbox@php-7.0.20 $ git-ignored --path=.
|
|
|
|
devilbox@php-7.0.20 $ file-cr --path=.
|
|
|
|
devilbox@php-7.0.20 $ file-crlf --path=.
|
|
|
|
devilbox@php-7.0.20 $ file-empty --path=.
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 4. Run tools with more options
|
|
|
|
devilbox@php-7.0.20 $ syntax-php --path=. --extension=php
|
|
|
|
devilbox@php-7.0.20 $ syntax-php --path=. --shebang=php
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 5. Various syntax checks
|
|
|
|
devilbox@php-7.0.20 $ syntax-bash --path=. --text --extension=sh
|
|
|
|
devilbox@php-7.0.20 $ syntax-css --path=. --text --extension=css
|
|
|
|
devilbox@php-7.0.20 $ syntax-js --path=. --text --extension=js
|
|
|
|
devilbox@php-7.0.20 $ syntax-json --path=. --text --extension=json
|
|
|
|
devilbox@php-7.0.20 $ syntax-markdown --path=. --text --extension=md
|
|
|
|
devilbox@php-7.0.20 $ syntax-perl --path=. --text --extension=pl
|
|
|
|
devilbox@php-7.0.20 $ syntax-php --path=. --text --extension=php
|
|
|
|
devilbox@php-7.0.20 $ syntax-python --path=. --text --extension=python
|
|
|
|
devilbox@php-7.0.20 $ syntax-ruby --path=. --text --extension=rb
|
|
|
|
devilbox@php-7.0.20 $ syntax-scss --path=. --text --extension=scss
|
2018-04-08 10:31:13 +00:00
|
|
|
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
PHPCS
|
|
|
|
=====
|
|
|
|
|
|
|
|
PHPCS is a code style analyser for PHP.
|
|
|
|
|
2018-07-10 18:59:52 +00:00
|
|
|
.. seealso:: |ext_lnk_tool_phpcs|
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 1. Enter your PHP container
|
|
|
|
host> ./bash
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 2. Go to your project folder
|
|
|
|
devilbox@php-7.0.20 $ cd /shared/httpd/my-project
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 3. Run it
|
|
|
|
devilbox@php-7.0.20 $ phpcs .
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
ESLint
|
|
|
|
======
|
|
|
|
|
|
|
|
ESLint is a Javascript static source code analyzer.
|
|
|
|
|
2018-07-10 18:59:52 +00:00
|
|
|
.. seealso:: |ext_lnk_tool_eslint|
|
2018-03-25 21:40:28 +00:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 1. Enter your PHP container
|
|
|
|
host> ./bash
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 2. Go to your project folder
|
|
|
|
devilbox@php-7.0.20 $ cd /shared/httpd/my-project
|
2018-03-25 21:40:28 +00:00
|
|
|
|
2018-06-03 18:45:01 +00:00
|
|
|
# 3. Run it
|
|
|
|
devilbox@php-7.0.20 $ eslint .
|