phpcs with VScode - how do I disable the line length warning? - visual-studio-code

I am working on some legacy code, and VScode is highlighting a lot of lines because of some warnings like Line exceeds 85 characters, contains 91 characters. It's pretty annoying, and I'd like to raise that limit to at least 120 chars, or even disable it completely.
My vertical ruler is already set to 120.
How can I move or remove that limit? I've been looking everywhere but I can't find a a working answer... this is my project's settings.json
{
"editor.wordWrapColumn": 120
}

Edit phpcs settings in VS Code and make sure "PHP Sniffer: Standard" is blank (so that it looks for your custom ruleset file).
Create file "phpcs.xml" in your project root, containing a ruleset like:
<?xml version="1.0"?>
<ruleset name="MyRuleset">
<!-- Scan all files in directory -->
<file>.</file>
<!-- Ignore Composer dependencies -->
<exclude-pattern>vendor/</exclude-pattern>
<!-- Show colors in console -->
<arg value="-colors"/>
<!-- Show sniff codes in all reports -->
<arg value="ns"/>
<!-- Use PSR-12 as a base -->
<rule ref="PSR12"/>
<rule ref="Generic.Files.LineLength.TooLong">
<severity>0</severity>
</rule>
</ruleset>

Related

Increase the maximum number of javadoc warnings when compiling with Ant

I recently upgraded my development environment from Java 7 to Java 8, which now finds a large number of previously-undetected javadoc issues.
By default, Ant (invoked via Eclipse Mars) limits its warnings (and I assume errors) to 100:
Is there any parameter to force Ant to display all javadoc warnings instead of limiting to 100?
I attempted to use the -Xmaxwarns 1000 parameter via the compilerarg element, but it appears that the current Ant version in Eclipse Mars (Ant 1.9.4) javadoc task does not support the compilerarg element (it is only supported in the javac task):
<!-- Generate the API documentation. -->
<target name="javadoc" depends="clean" description="Generate the API documentation.">
<!-- Create the build directory structure used by javadoc. -->
<mkdir dir="${build.folder}" />
<mkdir dir="${docs.folder}" />
<!-- Run javadoc. -->
<javadoc destdir="${docs.folder}/api" author="true" version="true" use="true" windowtitle="${documentation.title}">
<compilerarg value="-Xmaxerrs 1000 -Xmaxwarns 1000" />
<classpath>
...
Java 8 javadoc does support these parameters (support was added in Java 7 b100):
C:\>javadoc -X
-Xmaxerrs <number> Set the maximum number of errors to print
-Xmaxwarns <number> Set the maximum number of warnings to print
Provided by standard doclet:
-Xdocrootparent <url> Replaces all appearances of #docRoot followed
by /.. in doc comments with <url>
-Xdoclint Enable recommended checks for problems in javadoc comments
-Xdoclint:(all|none|[-]<group>)
Enable or disable specific checks for problems in javadoc comments,
where <group> is one of accessibility, html, missing, reference, or syntax.
These options are non-standard and subject to change without notice.
Conclusion: It appears that the Ant javadoc task is the limiting factor here, and if it supported the compilerarg flag, it would be possible to adjust the limit on errors and warnings.
As you noted, -Xmaxwarns affects how many warnings the javadoc program outputs.
-Xmaxwarns can be passed to the javadoc program with nested <arg> elements:
<javadoc ...>
<arg value="-Xmaxwarns"/>
<arg value="200"/>
</javadoc>
In my own test case, I was able to increase the reported warnings above 100:
[javadoc] Generating Javadoc
...
[javadoc] 112 warnings

Checkstyle Error in eclipse: cannot initialize module FilesFilter - Unable to instantiate FilesFilter

I am using checkstyle 5.7
I have written a custom FilesFilter as explained in the checkstyle documentation below,
http://checkstyle.sourceforge.net/writingfilters.html
As suggested in the documentation, I have written a java file and added an entry for it under "Checker" module in my config xml file.
So, this custom filter is supposed to ignore all files containing string "Test" in it's file name.
<module name="com.mycompany.myproject.filters.FilesFilter">
<property name="files" value="Test" />
</module>
Due to this entry in the config file, the check style is not loading in eclipse and gives following error,
cannot initialize module FilesFilter - Unable to instantiate
FilesFilter
Please help.
I think there is no straight solution for this yet. Or may be there is, if you are prepared to invest hours of your time.
Here's what I did as a workaround.
In eclipse, to disable checkstyles for a package (e.g. Test package in my case),
Go to, Project -> Properties -> Checkstyle
On Checkstyle Main tab, there is section "Exclude from checking.." with a set of check boxes.
Select the check box "files from packages:".
Click the "Change.." button in the right hand corner or just double click on "files from packages:"
Select the package you want Checkstyle to ignore. In my case I selected com/myproject/test/ package, and that was it. Checkstyle ignores all files in the test package.
If you are using Checkstyle as an ANT task, you may use excludes option as explained in the following code,
<target name="applyCheckStyle" depends="build" description="--> apply check style to all java files, excluding test package.">
<checkstyle config="${checkstyle.config}">
<fileset dir="${src.dir}" includes="**/*.java" excludes="**/test/**" />
<formatter type="plain" />
<formatter type="xml" toFile="${build.dir}/checkstyle_errors.xml" />
</checkstyle>
</target>
This worked for me :)

Joomla 3.1.4 ,JInstaller: :Install: Cannot find Joomla XML setup file,error

I have setup already joomla 3.1.4 and I tried to install a plugin,But Im getting this error:
JInstaller: :Install: Cannot find Joomla XML setup file
This is my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://www.joomla.org/xml/dtd/1.5/template-install.dtd">
<extension version="3.1" type="plugin" group="content" client="myjoomlasite">
<name>plg_content_helloworld</name>
<author>Tahsin Çetin</author>
<creationDate>July 27th,2013</creationDate>
<copyright>Tahsin Çetin</copyright>
<licence>GNU General Public License</licence>
<authorEmail>tcetin#yandex.com</authorEmail>
<authorUrl>http://tahsincetin.com</authorUrl>
<version>1.1.0</version>
<description>Simple Hello World plugin</description>
<files>
<filename plugin="helloworld">helloworld.php</filename>
<filename>index.html</filename>
<filename>helloworld.xml</filename>
</files>
</extension>
You do not need to specify "helloworld.xml" in your xml file.Remove file and install again.This will be your final xml file-
<?xml version="1.0" encoding="UTF-8"?>
<extension version="3.1" type="plugin" group="content" client="myjoomlasite">
<name>plg_content_helloworld</name>
<author>Tahsin Çetin</author>
<creationDate>July 27th,2013</creationDate>
<copyright>Tahsin Çetin</copyright>
<licence>GNU General Public License</licence>
<authorEmail>tcetin#yandex.com</authorEmail>
<authorUrl>http://tahsincetin.com</authorUrl>
<version>1.1.0</version>
<description>Simple Hello World plugin</description>
<files>
<filename plugin="helloworld">helloworld.php</filename>
<filename>index.html</filename>
</files>
</extension>
Hope this will help.
The "Cannot find Joomla XML setup file" usually means you are trying to install an extension that wasn't designed for the version of Joomla you are installing to.
Read more here
In your opening <extension> tag, you do not need to specify a client attribute.
Where is the XML file in relation to your ZIP package? If it isn't at the top level of the ZIP, it won't be found.
Generally when this happens something is wrong with the XML file. If you have made any changes, try to think where those changes were and find a problem with the XML file.
Problems could be:
No opening or closing tag. Closing tags are easy to miss. Count them, make sure there's an opening and a closing tag.
Duplicated tags. It's easy to add two labels or showons for example, especially if you are copying and pasting.
Space before the opening XML tag
No closing fieldset tag
No closing extension or config tag. Easily deleted if you are replacing the file
You can easily use a tool like this:
https://www.w3schools.com/xml/xml_validator.asp
Which will help you to find issues such as missing opening and closing tags.

How to Configure Rock Star Apps plugin in Eclipse for Concatenating and Compressing Javascripts

I am using the rockstarapps plugin for concatenating and compressing/minifying .js files with Google Closure.
I chose the option to rebuild files when a dependency changes but now I would like to change the dependencies, output file, etc... How do I do that?
What does the 'Add to Auto-Building' option do?
thank you,
DM
In the root of your project is an ant build file called .rockstarapps.
This is Xml and human readable.
The output file is specified near the top: <file name="path/to/file.js">
Auto Building: I assume this adds the file to the build section of .rockstarapps
The autobuilding option will only be activated if the files change, to add a new dependency, go to the .rockstarapps file and add up the line necessary, after saving just change some line into any of the dependencies and the file should be compiled with your new dependencies.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rockstarapps>
<file name="WebContent/js/extlib.core.all.js">
<min>false</min>
<comp>false</comp>
<closureCompiler>false</closureCompiler>
<gZip>false</gZip>
<resolveImports>false</resolveImports>
<urlRewriting>false</urlRewriting>
<autoBuild>true</autoBuild>
<lineLength>-1</lineLength>
<autoTimestamps>false</autoTimestamps>
<removeLogs>false</removeLogs>
<oldFileNames>false</oldFileNames>
<dependencies>
<file>WebContent/ExtLib/core/modernizr.tdm.js</file>
<file>WebContent/ExtLib/core/jquery-1.8.3.js</file>
<file>WebContent/ExtLib/core/custom-tdm-jqm.js</file>
<file>WebContent/ExtLib/core/jquery.mobile-1.3.0.js</file>
<file>WebContent/ExtLib/template/knockout-2.2.1.js</file>
</dependencies>
<properties/>
</file>
</rockstarapps>

Why is this simple ant file being marked as an error in Eclipse?

I have a very, very simple any build script:
<project name="quiz_jar" default="all">
<target name="all">
<jar destfile="/home/mike/export/quiz_all.jar" duplicate="preserve">
<archives>
<zips>
<files includes="/home/mike/export/quiz.jar" />
<files includes="/home/mike/download/jeuclid-3.1.9/repo/*.jar" />
</zips>
</archives>
<manifest>
<attribute name="Main-Class" value="com.antlersoft.quiz.ui.QuizFrame"/>
</manifest>
</jar>
</target>
</project>
It works fine when I run it as an Ant task in Eclipse (or from the command line)
However, in the Problems tab, it is marked with the following error:
Default target all does not exist in this
project
I found that if I change any character in the file (like in a path), the error flag goes away. I added a comment to make the error go away. Would still like to know what the problem was.
The closing tag </project> is missing. After adding it I get no errors or warnings in eclipse.
One problem is that you are not closing with a </project> tag, so Eclipse might not be seeing the <target>.
When I ran this from the command line I got a more informative message:
XML document structures must start and end within the same entity.
I was able to resolve this issue for myself by updating Maven. Right click on the project->Maven->Update Project.