Skip to content

Source Code Analysis

Source Code Analysis

This tutorial gives you a general overview how to do static code analysis from within the PHP container.

* available-tools * work-inside-the-php-container

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.

tool awesome ci

Terminal window
# 1. Enter your PHP container
host> ./bash
# 2. Go to your project folder
[email protected] $ cd /shared/httpd/my-project
# 3. Run the tools
[email protected] $ git-conflicts --path=.
[email protected] $ git-ignored --path=.
[email protected] $ file-cr --path=.
[email protected] $ file-crlf --path=.
[email protected] $ file-empty --path=.
# 4. Run tools with more options
[email protected] $ syntax-php --path=. --extension=php
[email protected] $ syntax-php --path=. --shebang=php
# 5. Various syntax checks
[email protected] $ syntax-bash --path=. --text --extension=sh
[email protected] $ syntax-css --path=. --text --extension=css
[email protected] $ syntax-js --path=. --text --extension=js
[email protected] $ syntax-json --path=. --text --extension=json
[email protected] $ syntax-markdown --path=. --text --extension=md
[email protected] $ syntax-perl --path=. --text --extension=pl
[email protected] $ syntax-php --path=. --text --extension=php
[email protected] $ syntax-python --path=. --text --extension=python
[email protected] $ syntax-ruby --path=. --text --extension=rb
[email protected] $ syntax-scss --path=. --text --extension=scss

PHPCS

PHPCS is a code style analyser for PHP.

tool phpcs

Terminal window
# 1. Enter your PHP container
host> ./bash
# 2. Go to your project folder
[email protected] $ cd /shared/httpd/my-project
# 3. Run it

ESLint

ESLint is a Javascript static source code analyzer.

tool eslint

Terminal window
# 1. Enter your PHP container
host> ./bash
# 2. Go to your project folder
[email protected] $ cd /shared/httpd/my-project
# 3. Run it