Skip to main content

Extendable codestyle checker and fixer

Project description

https://travis-ci.org/webpp-studio/codestyle.svg?branch=master

This script checks and auto fixes codestyle for all supported languages:

  1. PHP (phpcs)

  2. Python (flake8)

  3. Javascript (jscs and jshint)

  4. CSS (csscomb)

  5. HTML (htmlcs)

Installation

# First install the pip, npm and pear package managers
# Example for debian
sudo apt-get install python-pip npm php-pear

# Install codestyle and dependencies
pip install codestyle
npm install -g jshint jscs-fixer csscomb htmlcs walk brace-expansion
pear install PHP_CodeSniffer

Usage

usage: codestyle [-h] [-I] [-i] [-c] [-s standard-dir] [-l language name]
                 [-e glob pattern [glob pattern ...]]
                 target [target ...]

Check and fix a code style

positional arguments:
  target                files for a checking

optional arguments:
  -h, --help            show this help message and exit
  -I, --fix             auto fix codestyle errors if possible
  -i, --fix-only        Deprecated. Same as -I
  -c, --compact         Show a compact output
  -s standard-dir, --standard standard-dir
                        A path to a coding standard directory
  -l language name, --language language name
                        force set the language for a checking
  -e glob pattern [glob pattern ...], --exclude glob pattern [glob pattern ...]
                        Exclude paths/files from checking

Example

# check all supported files in directory recursive
codestyle /path/to/project/dir
# check set of files
codestyle test.js test.php test.py
# test directory with exclude rules
codestyle /path -x '*.html' -x './tests/excluded_dir'
# check file and try to fix errors
codestyle -i test.js
# check project with compact output (no detail errors information)
codestyle -c /path/to/project/dir
# check all project and save full report to file
codestyle /path/to/project &> report.txt

Dependencies

  1. phpcs

  2. phpcbf

  3. jshint (NodeJS)

  4. jscs-fixer (NodeJS)

  5. jscs (NodeJS)

  6. flake8

  7. csscomb (NodeJS)

  8. htmlcs >= 0.1.4 (NodeJS)

  9. walk (NodeJS)

  10. brace-expansion (NodeJS)

Usage from the docker container

Also you can use the docker container with all installed dependencies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codestyle-0.1.2.tar.gz (25.8 kB view details)

Uploaded Source

File details

Details for the file codestyle-0.1.2.tar.gz.

File metadata

  • Download URL: codestyle-0.1.2.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for codestyle-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3482a61540f13bf015e1e9ccf863dc38b5a445c6004b43f2b22c06f9e1c18a33
MD5 2256adb2ade771142f804da464541517
BLAKE2b-256 e9203b1bfa39f66d279ea21788f0b6224971eadb1088fb39f2d4333db261da5f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page