Skip to content
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

#127 [CI] add: PHPCS github action #18

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build Dolibarr 18.0
run: git clone https://github.com/dolibarr/dolibarr -b 18.0 && pwd

- name: Change directory in custom
run: cd dolibarr/htdocs/custom && pwd

- name: Build Saturne 1.2.0
run: git clone https://github.com/evarisk/saturne

- name: Change directory in saturne
run: cd saturne && pwd
# phpstan:
# runs-on: ubuntu-latest
# steps:s
- uses: actions/checkout@v3
- uses: php-actions/composer@v6

- name: PHPStan Static Analysis
uses: php-actions/phpstan@v3
with:
configuration: phpstan.neon

- name: LS
run: ls
28 changes: 28 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'PHP CodeSniffer Validations'
on: [push,pull_request]
jobs:
check-phpcs:
name: PSR-12 Code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Validate composer.json and composer.lock
run: composer validate

- name: Get composer Cache Directory
id: composer-cache
run: echo '::set-output name=dir::$(composer config cache-files-dir)'

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install PHP_CodeSniffer composer package
run: composer global require 'squizlabs/php_codesniffer=*'

- name: Validate PSR-12 Code Style
run: ~/.composer/vendor/bin/phpcs --standard=PSR12 -p ../
28 changes: 28 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 'PHPStan'
on: [push,pull_request]
jobs:
check-phpstan:
name: PHPStan CI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Validate composer.json and composer.lock
run: composer validate

- name: Get composer Cache Directory
id: composer-cache
run: echo '::set-output name=dir::$(composer config cache-files-dir)'

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install PHPStan composer package
run: composer require --dev phpstan/phpstan

- name: Analyse code with PHPStan
run: php ~/.composer/vendor/bin/phpstan -v analyze -a --memory-limit 5G --error-format=github
2 changes: 2 additions & 0 deletions class/saturneobject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ abstract class SaturneObject extends CommonObject
*/
public int $isextrafieldmanaged = 1;

public string $oldref = '';

/**
* Constructor.
*
Expand Down
8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "evarisk/saturne",
"description": "Saturne",
"license": "GPL-3.0-or-later",
"require-dev": {
"squizlabs/php_codesniffer": "*"
}
}
76 changes: 76 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 117 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
parameters:
customRulesetUsed: true
level: 1
fileExtensions:
- php
paths:
- htdocs
- scripts
excludePaths:
analyseAndScan:
- htdocs/custom
- htdocs/dev/*
- htdocs/doc/*
- htdocs/documents/*
- htdocs/install/doctemplates/*
- htdocs/langs/*
- htdocs/modulebuilder/template/test/*
- htdocs/support/*
- htdocs/test/*
analyse:
- htdocs/includes/*
checkAlwaysTrueCheckTypeFunctionCall: false
checkAlwaysTrueInstanceof: false
checkAlwaysTrueStrictComparison: false
checkClassCaseSensitivity: false
checkFunctionArgumentTypes: false
checkFunctionNameCase: false
checkArgumentsPassedByReference: false
checkMaybeUndefinedVariables: false
checkNullables: false
checkThisOnly: true
checkUnionTypes: false
checkExplicitMixedMissingReturn: false
checkPhpDocMissingReturn: false
reportMaybes: false
reportMaybesInMethodSignatures: false
reportStaticMethodSignatures: false
polluteScopeWithLoopInitialAssignments: true
polluteScopeWithAlwaysIterableForeach: true
reportMagicMethods: false
reportMagicProperties: false
ignoreErrors:
- '#Undefined variable: \$langs#'
- '#Undefined variable: \$user#'
- '#Undefined variable: \$db#'
- '#Undefined variable: \$conf#'
- '#Undefined variable: \$hookmanager#'
- '#Undefined variable: \$mysoc#'
- '#Undefined variable: \$error#'
- '#Undefined variable: \$errors#'
- '#Undefined variable: \$form#'
- '#has an unused parameter \$param#'
- '#Result of function fieldList#'
- '#Caught class Stripe#'
- '#Function llxHeader invoked with#'
- '#Function llxHeaderVierge invoked with#'
- '#Function llxFooter invoked with#'
- '#Function llxFooterVierge invoked with#'
- '#If condition is always true#'
- '#always exists and is not falsy#'
- '#has no return type specified#'
- '#is always true#'
- '#is always fal#'
- '#always exists and is not nullable#'
- '#PHPDoc tag @return has invalid value#'
- '#type has no value type specified in iterable type array#'
- '#with no value type specified in iterable type array#'
- '#Empty array passed to foreach#'
- '#in isset\(\) is not nullable#'
- '#Sprain\\SwissQrBill\\#'
internalErrorsCountLimit: 50
cache:
nodesByFileCountMax: 512
nodesByStringCountMax: 512
reportUnmatchedIgnoredErrors: false
universalObjectCratesClasses:
- stdClass
- SimpleXMLElement
earlyTerminatingMethodCalls: []
dynamicConstantNames:
- ICONV_IMPL
- PHP_VERSION
- PHP_MAJOR_VERSION
- PHP_MINOR_VERSION
- PHP_RELEASE_VERSION
- PHP_VERSION_ID
- PHP_EXTRA_VERSION
- PHP_ZTS
- PHP_DEBUG
- PHP_MAXPATHLEN
- PHP_OS
- PHP_OS_FAMILY
- PHP_SAPI
- PHP_EOL
- PHP_INT_MAX
- PHP_INT_MIN
- PHP_INT_SIZE
- PHP_FLOAT_DIG
- PHP_FLOAT_EPSILON
- PHP_FLOAT_MIN
- PHP_FLOAT_MAX
- DEFAULT_INCLUDE_PATH
- PEAR_INSTALL_DIR
- PEAR_EXTENSION_DIR
- PHP_EXTENSION_DIR
- PHP_PREFIX
- PHP_BINDIR
- PHP_BINARY
- PHP_MANDIR
- PHP_LIBDIR
- PHP_DATADIR
- PHP_SYSCONFDIR
- PHP_LOCALSTATEDIR
- PHP_CONFIG_FILE_PATH
- PHP_CONFIG_FILE_SCAN_DIR
- PHP_SHLIB_SUFFIX
- PHP_FD_SETSIZE
15 changes: 15 additions & 0 deletions phpstan.neon.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
includes:
- ../../../../phpstan.neon

parameters:
customRulesetUsed: true
level: 1
fileExtensions:
- php
paths:
- admin
- class
- core
- lib
- public
- view
Loading