Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save josephdpurcell/ca2572a1f2764c1fe930885c29d06382 to your computer and use it in GitHub Desktop.
Save josephdpurcell/ca2572a1f2764c1fe930885c29d06382 to your computer and use it in GitHub Desktop.
Patch to add Code Climate configuration to Drupal 8 Modules
From 84faa57d401b07df3f5cf645519614604e257c10 Mon Sep 17 00:00:00 2001
From: "Joseph D. Purcell" <[email protected]>
Date: Sun, 24 Jul 2016 16:20:12 -0500
Subject: [PATCH] Add Code Climate config for Drupal 8 modules
---
.codeclimate.yml | 25 ++++++++++++++++++
.phpmd.xml | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+)
create mode 100644 .codeclimate.yml
create mode 100644 .phpmd.xml
diff --git a/.codeclimate.yml b/.codeclimate.yml
new file mode 100644
index 0000000..329c582
--- /dev/null
+++ b/.codeclimate.yml
@@ -0,0 +1,25 @@
+---
+engines:
+ phpmd:
+ enabled: true
+ config:
+ file_extensions: "php,inc,module"
+ rulesets: ".phpmd.xml"
+ phpcodesniffer:
+ enabled: true
+ config:
+ file_extensions: "php,inc,module"
+ encoding: utf-8
+ standard: "Drupal"
+ ignore_warnings: true
+ratings:
+ paths:
+ - "*.module"
+ - "*.install"
+ - "src/**.php"
+exclude_paths:
+- "**/Test/**/*"
+- config
+- css
+- templates
+- tests
diff --git a/.phpmd.xml b/.phpmd.xml
new file mode 100644
index 0000000..c1a66cf
--- /dev/null
+++ b/.phpmd.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<ruleset xmlns="http://pmd.sourceforge.net/ruleset/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PMD Ruleset for Drupal" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
+ <description>
+ A PMD Ruleset for Drupal coding standards.
+ </description>
+
+ <!--
+ Include each rule explicitly so we know what we have.
+ @see https://github.com/phpmd/phpmd/blob/master/src/main/resources/rulesets/
+ -->
+
+ <!-- Clean Code -->
+ <!--
+ These don't align with Drupal standards, so they are excluded.
+ @todo Static calls are hard to test and extend, is there a way to whitelist the ones that are OK?
+ <rule ref="rulesets/cleancode.xml/BooleanArgumentFlag"/>
+ <rule ref="rulesets/cleancode.xml/ElseExpression"/>
+ <rule ref="rulesets/cleancode.xml/StaticAccess"/>
+ -->
+
+ <!-- Code Size -->
+ <rule ref="rulesets/codesize.xml/CyclomaticComplexity"/>
+ <rule ref="rulesets/codesize.xml/NPathComplexity"/>
+ <rule ref="rulesets/codesize.xml/ExcessiveMethodLength"/>
+ <rule ref="rulesets/codesize.xml/ExcessiveClassLength"/>
+ <rule ref="rulesets/codesize.xml/ExcessiveParameterList"/>
+ <rule ref="rulesets/codesize.xml/ExcessivePublicCount"/>
+ <rule ref="rulesets/codesize.xml/TooManyFields"/>
+
+ <!-- Controversial -->
+ <rule ref="rulesets/controversial.xml/Superglobals"/>
+ <!--
+ These checks do not need to be included since PHPCS will check for style.
+ <rule ref="rulesets/controversial.xml/CamelCaseClassName"/>
+ <rule ref="rulesets/controversial.xml/CamelCasePropertyName"/>
+ <rule ref="rulesets/controversial.xml/CamelCaseMethodName"/>
+ <rule ref="rulesets/controversial.xml/CamelCaseParameterName"/>
+ <rule ref="rulesets/controversial.xml/CamelCaseVariableName"/>
+ -->
+
+ <!-- Design -->
+ <rule ref="rulesets/design.xml/ExitExpression"/>
+ <rule ref="rulesets/design.xml/EvalExpression"/>
+ <rule ref="rulesets/design.xml/GotoStatement"/>
+ <rule ref="rulesets/design.xml/NumberOfChildren"/>
+ <rule ref="rulesets/design.xml/DepthOfInheritance"/>
+ <rule ref="rulesets/design.xml/CouplingBetweenObjects"/>
+ <rule ref="rulesets/design.xml/DevelopmentCodeFragment"/>
+
+ <!-- Naming -->
+ <rule ref="rulesets/naming.xml/ShortVariable">
+ <properties>
+ <!-- Allow $id as a variable name. -->
+ <property name="exceptions" description="Comma-separated list of exceptions" value="id"/>
+ </properties>
+ </rule>
+ <rule ref="rulesets/naming.xml/LongVariable">
+ <properties>
+ <!-- Bump variable length to a more reasonable number. -->
+ <property name="maximum" description="The variable length reporting threshold" value="35"/>
+ </properties>
+ </rule>
+ <rule ref="rulesets/naming.xml/ShortMethodName"/>
+ <rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass"/>
+ <rule ref="rulesets/naming.xml/ConstantNamingConventions"/>
+ <rule ref="rulesets/naming.xml/BooleanGetMethodName"/>
+
+ <!-- Unused Code -->
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateField"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedLocalVariable"/>
+ <rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod"/>
+ <!--
+ Hooks often have unused parameters, so ignore this warning.
+ @todo is there a way to allow unused parameters in hooks but not elsewhere?
+ <rule ref="rulesets/unusedcode.xml/UnusedFormalParameter"/>
+ -->
+
+</ruleset>
--
2.7.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment