diff --git a/.gitignore b/.gitignore index 5aeaa1a3dee6b6e54ccdbfdd601c6235344005b6..ec72cb6cf35d54a085d5ec9ab611928ea0cbdf9d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ /components/ /composer.lock /apigen -/nbproject/private/ \ No newline at end of file +/nbproject +/.php_cs.cache +/.idea diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..6534a7bb8de0f348f6db5011148b8e275069b81b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,66 @@ + +cache: + key: "$CI_COMMIT_REF_NAME-$CI_JOB_NAME" + paths: + - $HOME/.composer/cache + - vendor/ + +variables: + COMPOSER_NO_INTERACTION: "1" + COMPOSER_ALLOW_SUPERUSER: "1" + S6_TARGET: none + DEBIAN_FRONTEND: noninteractive + +phpunit: + stage: test + tags: [docker] + image: isdevtools.irstea.fr/poleis/php-apache2:stretch-7.1 + before_script: + - phpenmod pdo_sqlite curl + - composer update --prefer-dist --no-progress --ansi --no-suggest --prefer-stable + script: + - vendor/bin/phpunit + +.static-analysis: &static-analysis + stage: test + tags: [docker] + image: isdevtools.irstea.fr/poleis/php-analysis:7.1 + +phploc: + <<: *static-analysis + script: + - phploc --exclude=vendor . + +lint: + <<: *static-analysis + script: + - parallel-lint -j $(nproc) --exclude vendor . + +phpcs: + <<: *static-analysis + script: + - phpcs --colors --parallel=$(nproc) . + allow_failure: true + +phpcpd: + <<: *static-analysis + script: + - phpcpd --exclude=vendor --fuzzy . + +phpmd: + <<: *static-analysis + script: + - phpmd . text ./phpmd.xml --suffixes=php + allow_failure: true + +satis: + stage: deploy + tags: [shell] + image: alpine + variables: + GIT_STRATEGY: none + before_script: + - apk update && apk add curl + script: + - curl -sS "https://isdevtools.irstea.fr/satis/trigger.php?package=irstea/$CI_PROJECT_NAME" + diff --git a/.php_cs.dist b/.php_cs.dist new file mode 120000 index 0000000000000000000000000000000000000000..6794dc559ca047549927a1a4adb79cf15ecd0d51 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1 @@ +/home/guillaume.perreal/.config/devtools/php/.php_cs.dist \ No newline at end of file diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000000000000000000000000000000000000..ded85440258b1ebe6c76af2c9c322b09748daf1a --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,23 @@ +<?xml version="1.0"?> +<ruleset name="Irstea" namespace="Irstea\Standard"> + + <description>Coding standard of Irstea, pôle informatique scientifique</description> + + <file>src</file> + + <arg name="encoding" value="utf-8"/> + <arg value="sp"/> + + <rule ref="PSR2"/> + + <rule ref="Generic.Files.LineLength"> + <properties> + <property name="lineLimit" value="140"/> + </properties> + </rule> + + <exclude-pattern>vendor/</exclude-pattern> + <exclude-pattern>node_modules/</exclude-pattern> + <exclude-pattern>cache/</exclude-pattern> + +</ruleset> diff --git a/phpmd.xml b/phpmd.xml index bd97d4f36f7dc26b983649ee7663e048687a4e27..a773130258f9462dd7f966ab3b1411a60646e8a5 100755 --- a/phpmd.xml +++ b/phpmd.xml @@ -1,30 +1,34 @@ <?xml version="1.0"?> -<ruleset name="SYGADE PHPMD rule set" +<ruleset name="Irstea PHPMD ruleset" xmlns="http://pmd.sf.net/ruleset/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd" - xsi:noNamespaceSchemaLocation=" http://pmd.sf.net/ruleset_xml_schema.xsd"> + xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"> - <rule ref="rulesets/codesize.xml/ExcessiveMethodLength" /> - <rule ref="rulesets/codesize.xml/ExcessiveClassLength" /> - <rule ref="rulesets/codesize.xml/ExcessiveParameterList" /> + <description>Irstea ruleset</description> - <rule ref="rulesets/controversial.xml" /> - <rule ref="rulesets/unusedcode.xml" /> + <rule ref="rulesets/unusedcode.xml"/> + <rule ref="rulesets/codesize.xml"/> + <rule ref="rulesets/design.xml"/> + <rule ref="rulesets/controversial.xml"/> - <rule ref="rulesets/design.xml/ExitExpression" /> - <rule ref="rulesets/design.xml/EvalExpression" /> - <rule ref="rulesets/design.xml/GotoStatement" /> + <rule ref="rulesets/cleancode.xml/StaticAccess"> + <properties> + <property name="exceptions" value="\DateTime,\DateTimeZone,\Doctrine\DBAL\Types\ConversionException"/> + </properties> + </rule> + + <rule ref="rulesets/naming.xml"> + <exclude name="ShortVariable"/> + </rule> <rule ref="rulesets/naming.xml/ShortVariable"> <properties> - <property name="exceptions" value="id,em" /> + <property name="exceptions" value="em,tz,i,j,id,x,y,dn,fh,ex"/> </properties> </rule> - <rule ref="rulesets/naming.xml/LongVariable" /> - <rule ref="rulesets/naming.xml/ShortMethodName" /> - <rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" /> - <rule ref="rulesets/naming.xml/ConstantNamingConventions" /> - <rule ref="rulesets/naming.xml/BooleanGetMethodName" /> + + <exclude-pattern>vendor/</exclude-pattern> + <exclude-pattern>node_modules/</exclude-pattern> + <exclude-pattern>.*/cache/</exclude-pattern> </ruleset>