how to make opsway/psr12-strict-coding-standard only run on files that are being commited - psr-12

I am trying to use the composer package opsway/psr12-strict-coding-standard to make my code into psr12 standard, however, when trying to do commits the package runs in my github hook as expected but it runs on all the files in the project, including those which are not being commited, this is an issue due to all the files which do not end in the linux format which is every single file that has not been touched, I do not mind chaning the filetype manually for commit files but changing 20 or so files for a 1 file commit is a bit ridiculous, not sure if this is possible but hopefully there is.
Here is the config xml file
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<arg name="basepath" value="."/>
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="parallel" value="10"/>
<!-- Show progress -->
<arg value="p"/>
<!-- Paths to check -->
<file>app/Http/Controllers</file>
<file>app/Http/Traits</file>
<file>app/Http/Requests</file>
<file>app/Models</file>
<file>routes</file>
<!-- Include all rules from the Zend Coding Standard -->
<rule ref="OpsWayStrictPSR12CodingStandard"/>

Related

Ant task to compile stylus file to normal css file?

I am trying to use stylus in a project, that is using ANT build.
I need to compile the stylus file to normal css before packaging the war.
is there a way to do it?
Note : I am not using node.js, it is a simple java web application
Here is a full example how to use it:
<property name="css.stylus" value="../folder/to/stylus/files"/>
<property name="cmd.node" value="C:\Program Files\nodejs\nodevars.bat"/>
<property name="cmd.stylus" value="C:\Program Files\nodejs\stylus.cmd"/>
<target name="css_compile" description="compile l'ensemble des CSS avec stylus">
<exec executable="${cmd.node}" />
<exec dir="${css.stylus}" executable="${cmd.stylus}" >
<arg value="myCSS.styl"/>
<arg value="-c"/>
<arg value="-o"/>
<arg value="..\cssFolder"/>
</exec>
</target>
This example (I used) transform myCSS.styl in a obfuscate CSS to /cssFolder
nodevars.bat is necessary for launching stylus.
stylus.cmd is stylus itself, because the path not working in ant. To know where is it, (it's in nodejs), you can type "path" in terminal, on Windows.
That's all!

No ruleset or basic.xml in the sourceforge pmd-bin-5.0.0 download

I've been reading all over the PMD Website and it has all these references to <rule ref="rulesets/basic.xml/UnnecessaryConversionTemporary"/> but I cant find the file basic.xml in either the pmd-bin-5.0.0 or pmd-bin-5.0-alpha directory downloaded from sourceforge.
As you can see in the screen dump I've provided below, I've done a search for this basic.xml and came up empty handed.
(source: iforce.co.nz)
In the next screen shot of pmd-bin-5.0.0 there is no folder called ruleset
(source: iforce.co.nz)
Pastebin link to ruleset.xml (Expires in 24 hours)
<property name="pmd.dir" value="${basedir}/pmd" /><!-- directory that contains pmd.jar -->
<property name="pmd.test.results" location="${build.dir}/pmd"/>
<path id="pmd.lib" >
<fileset dir="${pmd.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="pmd" depends="compile" >
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.lib"/>
<pmd shortFilenames="true">
<ruleset>basic,imports</ruleset>
<formatter type="text" toFile="pmd-ant-results.txt"/>
<fileset dir="src">
<include name="**/*.java"/>
</fileset>
</pmd>
</target>
When my ant script is executed it comes back with this error
[pmd] net.sourceforge.pmd.RuleSetNotFoundException: Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH.
BUILD FAILED
C:\Users\Michael\Desktop\log4jassignment.s06005586\build.xml:131: java.lang.RuntimeException: Couldn't find the class Can't find resource rulesets/basic.xml. Make sure the resource is a valid file or URL or is on the CLASSPATH.
Project Explorer
(source: iforce.co.nz)
So that tells me that the basic.xml file doesn't come from the pmd-5.0.0.jar file but in fact comes from somewhere else, Thus my question is what is the contents of pmd's basic.xml, and other required xml files (how am I meant to get my hands on them)? or do these files not exist and am I meant to recreate them myself (and if I am, how would I go about doing this?)?
I downloaded pmd-bin-5.0-alpha.zip from PMD Website.
Once you unzip pmd-bin-5.0-alpha.zip file;
go inside the lib directory and
try to extract the content of pmd-5.0-alpha.jar.
I was able to find the following:

blackberry build using hudson signing automation not at configure page but inside the build

I know the automation of signature for blackberry app, as "java -jar ..signaturetool.jar....",
when I am building using hudson, i have to give at project config page by calling execute windows batch command ant task.
But am writing a build which is common for different clients, that time i want to include
this automation of signing within the build,as my app name will be changed according to the client's name and the path will be changed, so i want to execute this command line within the build, i tried this, but not working, its not executing the exec ant task.
Can anyone help me where am missing, this is the code:
<property name="signpath" location="C:/Program Files/Research In Motion/BlackBerry JDE 5.0.0/bin/SignatureTool.jar"/>
<exec executable ="cmd" os="Windows XP" >
<arg line="java -jar ${signpath} -a -c -p pswd ${codfilepath}/${uid}/${uName}_${version}_${server}.cod"/>
</exec>
I use the following ANT target for signing. It requires the use of bb_ant_tools (which seems to be an industry standard, at least among stackoverflow users).
<target name="sign" depends=""
description="Signs the final COD file by calling the BlackBerry signing server. The password is stored in the common.properties file." >
<sigtool
codfile="${cod.output.dir}/${project.output}.cod"
jdehome="${sigtool.jde}"
password="${sigtool.password}"
/>
</target>
All the parameters are stored in various properties files (I recommend keeping your signature password in a separate properties file to the rest of your project settings).
I would recommend this approach, since bb_ant_tools offers many useful features.
As to why the exec isn't working, I have had problems with exec when putting all parameters in one tag.
Try something like:
<exec executable="java" >
<arg value="-jar" />
<arg value="${signpath}" />
<arg value="-a" />
<arg value="-c" />
<arg value="-p" />
<arg value="pswd " />
<arg value="${codfilepath}/${uid}/${uName}_${version}_${server}.cod" />
</exec>
In my experience, each "space" character in the command line means you need to add a new <arg value="...." /> line to the script. ymmv.

How do I convert textile to Eclipse help using ant?

I've been using the Mylyn WikiText User Guide to learn how to convert textile files to Eclipse help but I also want to be able to do this using ant because, ultimately, I want to have many textile files contribute to a single textile file then convert to Eclipse help to enable multiple developers to create help pages with minimal conflicts.
The following ant script should take all *.textile files in the 'doc' folder and convert them to Eclipse help:
<?xml version="1.0"?>
<project name="helpwikitext" default="generate-help">
<property name="wikitext.standalone" value="doc" />
<path id="wikitext.classpath">
<fileset dir="${wikitext.standalone}">
<include name="org.eclipse.mylyn.wikitext.*core*.jar" />
</fileset>
</path>
<taskdef classpathref="wikitext.classpath" resource="org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties" />
<target name="generate-help" description="Generate Eclipse help from textile source">
<wikitext-to-eclipse-help markupLanguage="Textile" multipleOutputFiles="true" navigationImages="true" helpPrefix="help">
<fileset dir="${basedir}">
<include name="doc/*.textile" />
</fileset>
<stylesheet url="styles/help.css" />
<stylesheet url="styles/main.css" />
</wikitext-to-eclipse-help>
</target>
</project>
I get the following error:
[taskdef] Could not load definitions from resource org/eclipse/mylyn/wikitext/core/util/anttask/tasks.properties. It could not be found.
build.xml:11: Problem: failed to create task or type wikitext-to-eclipse-help
I'm fairly sure that I have all the Mylyn features installed so it looks like the ant script doesn't know where to find them. Does anyone know how to fix this?
Do you have the wikitext standalone package installed in your doc directory?
That is what is expected as you define the path used by the taskdef like this:
<property name="wikitext.standalone" value="doc" />
I'll take a guess that your wikitext package is in a different dir.
You then use the same dir as the root for your textfiles. I would suggest to keep the wikitext standalone package separate from your textfiles.

How to get Flex Builder 3 to generate two builds: one "-use-network=true", another "-use-network=false"?

I'm building a Flex application that will need run under two different deployment scenarios:
First, the application will be hosted on the web. The SWF loads some external resources (images, text) so it requires network access, which is the Flex Builder 3 default build flag "-use-network=true". I don't need to do anything special; it just works.
Second, the application will be written to CD with autorun enabled to launch the index.html hosting the SWF. The SWF still needs to be able to load those same external resources, which reside on the CD in a subfolder. Since those files are on the CD, they are considered local, so Flash security requires the SWF to be built using a flag of "-use-network=false". I add that to the "Additional compiler arguments" text box found under "Flex Compiler" in the Flex project's Properties dialog.
That all works as expected, but it's tedious to have to manually modify the Flex Builder project settings to add or remove that flag as the case may be.
Ideally, I would like to just build the project once and have multiple output folders: one for the network deployment scenario, and another for the local deployment scenario.
What's the best way to do that? Is moving to an Ant build the way to go, or is there a simpler way? If an Ant build configuration is the correct way, do you have an example to share of such multiple build configurations?
Thanks for your help!
Once you get your head around the Ant build, it will make your life a lot easier. Building a multiple build file is no different from a single build file, you will just add an additional task inside of your build with the appropriate settings (you could also use a loop in ant, but that adds complexity)
So, expanding on the Flex Ant Tasks example from the docs, something like this should work (not-tested):
<?xml version="1.0" encoding="utf-8"?>
<!-- myMXMLCBuild.xml -->
<project name="My App Builder" basedir="." default="main">
<taskdef resource="flexTasks.tasks" classpath="${basedir}/flexTasks/lib/flexTasks.jar" />
<property name="FLEX_HOME" value="C:/flex/sdk"/>
<property name="APP_ROOT" value="apps"/>
<property name="DEPLOY_DIR" value="c:/jrun4/servers/default/default-war"/>
<target name="main" depends="clean, compile1, compile2">
</target>
<target name="compile1">
<mxmlc
file="${APP_ROOT}/Main.mxml"
output="${DEPLOY_DIR}/Main.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="true"
incremental="true"
use-network="true"
>
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<!-- List of path elements that form the roots of ActionScript
class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="../bundles/{locale}" />
</compiler.library-path>
<!-- Set size of output SWF file. -->
<default-size width="500" height="600" />
</mxmlc>
</target>
<target name="compile2">
<mxmlc
file="${APP_ROOT}/Main.mxml"
output="${CD_DEPLOY_DIR}/Main.swf"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="true"
incremental="true"
use-network="false"
>
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<!-- List of path elements that form the roots of ActionScript
class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="../bundles/{locale}" />
</compiler.library-path>
<!-- Set size of output SWF file. -->
<default-size width="500" height="600" />
</mxmlc>
</target>
<target name="clean">
<delete dir="${APP_ROOT}/generated"/>
<delete>
<fileset dir="${DEPLOY_DIR}" includes="Main.swf"/>
</delete>
</target>
</project>
As a side note, if you are going to be running the Ant build in eclipse/Flash Builder you might as well increase the memory now.

Resources