-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Add option to allow having an undercore in test methods #257
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,115 @@ | ||
==================== | ||
PHPMD ant task usage | ||
==================== | ||
To ease the usage of PHPMD in your build process we provide an `ant task`__ | ||
that integrates PHPMD into the `ant`__ build tool. The ant task jar file can | ||
be found in the `download`__ section of the PHPMD homepage. | ||
__ http://ant.apache.org/manual/targets.html | ||
__ http://ant.apache.org/ | ||
__ /download/extensions#ant-task | ||
To make the task available in your ant build file you have two options. | ||
The first option is to copy or link the ``*.jar`` file into the ``lib`` | ||
directory of your ant installation. :: | ||
mapi@arwen ~ $ wget \ | ||
http://phpmd.org/download/extensions/ant-phpmd-0.1.0.jar | ||
... | ||
mapi@arwen ~ $ ln -s ~/ant-phpmd-0.1.0.jar /opt/ant/lib/ant-phpmd.jar | ||
The second option is to call ant with the command line switch ``-lib`` :: | ||
mapi@arwen ~ $ ant -lib ant-phpmd-0.1.0.jar | ||
Now we can start using PHPMD in our ant ``build.xml`` file by adding | ||
a task definition that informs ant about the new task and registers | ||
it with a custom identifier. :: | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project name="phpmd.example" default="example" basedir="."> | ||
<taskdef name="phpmd" classname="org.phpmd.ant.PHPMDTask"/> | ||
</project> | ||
Now the PHPMD task can be called through an xml element named ``<phpmd />`` | ||
in this build: :: | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="phpmd.example" default="example" basedir="."> | ||
<taskdef name="phpmd" classname="org.phpmd.ant.PHPMDTask"/> | ||
<target name="example"> | ||
<phpmd rulesetfiles="unusedcode" failonerror="off"> | ||
<formatter type="xml" toFile="${basedir}/pmd.xml" /> | ||
<fileset dir="${basedir}/PHPMD"> | ||
<include name="*.php" /> | ||
</fileset> | ||
</phpmd> | ||
</target> | ||
</project> | ||
Parameters | ||
========== | ||
The following attributes can be defined on the PHPMD task xml-element. | ||
===================== ========================================================================================================================= ================================================ | ||
Attribute Description Required | ||
===================== ========================================================================================================================= ================================================ | ||
rulesetfiles A comma delimited list of ruleset files ('rulesets/basic.xml,rulesets/design.xml') or identifiers of build-in rulesets. Yes, unless the ruleset nested element is used | ||
failonerror Whether or not to fail the build if any errors occur while processing the files No | ||
failOnRuleViolation Whether or not to fail the build if PHPMD finds any problems No | ||
minimumPriority The rule priority threshold; rules with lower priority than they will not be used No | ||
===================== ========================================================================================================================= ================================================ | ||
Nested xml elements | ||
=================== | ||
The ``<formatter />`` specifies the format of and the output file to | ||
which the report is written. | ||
**Parameters** | ||
=========== =================================================================== ========== | ||
Attribute Description Required | ||
=========== =================================================================== ========== | ||
format The report output format. Supported formats are xml,html and text. Yes | ||
toFile A filename into which the report is written Yes | ||
=========== =================================================================== ========== | ||
The ``<ruleset />`` xml element is another way to specify rulesets. Here | ||
is a modified version of the previous example: :: | ||
<target name="example"> | ||
<phpmd failonerror="off"> | ||
<formatter type="text" toFile="${basedir}/pmd.xml" /> | ||
<ruleset>unusedcode</ruleset> | ||
<ruleset>codesize</ruleset | ||
<fileset dir="${basedir}/PHPMD"> | ||
<include name="*.php" /> | ||
</fileset> | ||
</phpmd> | ||
</target> | ||
Postprocessing the report file with XSLT | ||
======================================== | ||
There are several XSLT scripts which can be used to transform the XML | ||
report into some nice html pages. To do this, make sure you use the | ||
XML formatter in the PHPMD task invocation, i.e.: :: | ||
<formatter type="xml" toFile="${builddir}/~report.xml"/> | ||
Then, after the end of the PHPMD task, do this: :: | ||
<xslt in="${builddir}/~report.xml" | ||
style="${basedir}/report.xslt" | ||
out="${reportdir}/report.html" /> | ||
==================== | ||
PHPMD ant task usage | ||
==================== | ||
|
||
To ease the usage of PHPMD in your build process we provide an `ant task`__ | ||
that integrates PHPMD into the `ant`__ build tool. The ant task jar file can | ||
be found in the `download`__ section of the PHPMD homepage. | ||
|
||
__ http://ant.apache.org/manual/targets.html | ||
__ http://ant.apache.org/ | ||
__ /download/extensions#ant-task | ||
|
||
To make the task available in your ant build file you have two options. | ||
The first option is to copy or link the ``*.jar`` file into the ``lib`` | ||
directory of your ant installation. :: | ||
|
||
mapi@arwen ~ $ wget \ | ||
http://phpmd.org/download/extensions/ant-phpmd-0.1.0.jar | ||
... | ||
mapi@arwen ~ $ ln -s ~/ant-phpmd-0.1.0.jar /opt/ant/lib/ant-phpmd.jar | ||
|
||
The second option is to call ant with the command line switch ``-lib`` :: | ||
|
||
mapi@arwen ~ $ ant -lib ant-phpmd-0.1.0.jar | ||
|
||
|
||
Now we can start using PHPMD in our ant ``build.xml`` file by adding | ||
a task definition that informs ant about the new task and registers | ||
it with a custom identifier. :: | ||
|
||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project name="phpmd.example" default="example" basedir="."> | ||
|
||
<taskdef name="phpmd" classname="org.phpmd.ant.PHPMDTask"/> | ||
|
||
</project> | ||
|
||
Now the PHPMD task can be called through an xml element named ``<phpmd />`` | ||
in this build: :: | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="phpmd.example" default="example" basedir="."> | ||
|
||
<taskdef name="phpmd" classname="org.phpmd.ant.PHPMDTask"/> | ||
|
||
<target name="example"> | ||
<phpmd rulesetfiles="unusedcode" failonerror="off"> | ||
<formatter type="xml" toFile="${basedir}/pmd.xml" /> | ||
<fileset dir="${basedir}/PHPMD"> | ||
<include name="*.php" /> | ||
</fileset> | ||
</phpmd> | ||
</target> | ||
|
||
</project> | ||
|
||
Parameters | ||
========== | ||
|
||
The following attributes can be defined on the PHPMD task xml-element. | ||
|
||
===================== ========================================================================================================================= ================================================ | ||
Attribute Description Required | ||
===================== ========================================================================================================================= ================================================ | ||
rulesetfiles A comma delimited list of ruleset files ('rulesets/basic.xml,rulesets/design.xml') or identifiers of build-in rulesets. Yes, unless the ruleset nested element is used | ||
failonerror Whether or not to fail the build if any errors occur while processing the files No | ||
failOnRuleViolation Whether or not to fail the build if PHPMD finds any problems No | ||
minimumPriority The rule priority threshold; rules with lower priority than they will not be used No | ||
===================== ========================================================================================================================= ================================================ | ||
|
||
Nested xml elements | ||
=================== | ||
|
||
The ``<formatter />`` specifies the format of and the output file to | ||
which the report is written. | ||
|
||
**Parameters** | ||
|
||
=========== =================================================================== ========== | ||
Attribute Description Required | ||
=========== =================================================================== ========== | ||
format The report output format. Supported formats are xml,html and text. Yes | ||
toFile A filename into which the report is written Yes | ||
=========== =================================================================== ========== | ||
|
||
The ``<ruleset />`` xml element is another way to specify rulesets. Here | ||
is a modified version of the previous example: :: | ||
|
||
<target name="example"> | ||
<phpmd failonerror="off"> | ||
<formatter type="text" toFile="${basedir}/pmd.xml" /> | ||
<ruleset>unusedcode</ruleset> | ||
<ruleset>codesize</ruleset | ||
<fileset dir="${basedir}/PHPMD"> | ||
<include name="*.php" /> | ||
</fileset> | ||
</phpmd> | ||
</target> | ||
|
||
Postprocessing the report file with XSLT | ||
======================================== | ||
|
||
There are several XSLT scripts which can be used to transform the XML | ||
report into some nice html pages. To do this, make sure you use the | ||
XML formatter in the PHPMD task invocation, i.e.: :: | ||
|
||
<formatter type="xml" toFile="${builddir}/~report.xml"/> | ||
|
||
Then, after the end of the PHPMD task, do this: :: | ||
|
||
<xslt in="${builddir}/~report.xml" | ||
style="${basedir}/report.xslt" | ||
out="${reportdir}/report.html" /> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...CamelCaseMethodName/testRuleAppliesToTestMethodWithTwoUnderscoresEvenWhenOneIsAllowed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
class testRuleAppliesToTestMethodWithTwoUnderscoresEvenWhenOneIsAllowed | ||
{ | ||
public function testGivenSomeValue_expectSome_niceResult() | ||
{ | ||
|
||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ersial/CamelCaseMethodName/testRuleAppliesToTestMethodWithUnderscoreFollowedByCapital.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
class testRuleAppliesToTestMethodWithUnderscoreFollowedByCapital | ||
{ | ||
public function testGivenSomeValue_ExpectSomeResult() | ||
{ | ||
|
||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified to only allow:
3 or more words (including "test") before the _
2 or more words after the _
or 1 or more words but no underscore
A word starts with an uper case A-Z, then zero or more lower case a-z, then zero or more numbers 0-9 are allowed.
/^test(([A-Z][a-z][0-9])+|([A-Z][a-z][0-9]){3,}_{2,}))$/
Tests not included. Wielding this regexp is unsafe without first properly testing it.