Inspect Subdirectories of an Excluded Folder with PHP CodeSniffer - phpcodesniffer

I am attempting to configure my phpcs.xml (PHP CodeSniffer configuration file) so that I can exclude all directories from inspection within a folder except for those that I specify.
For those familiar with .gitignore, an equivalent would be something like this so that "ButIncludeThisOne" is included in version control.
/ignoreContentsWithin/*
!/ignoreContentsWithin/ButIncludeThisOne
What I have tried
Here is my phpcs.xml file:
<?xml version="1.0"?>
<ruleset name="MyRuleset">
...
<!-- Exclude Plugin Folders. -->
<exclude-pattern>/cms/wp-content/plugins/*</exclude-pattern>
<!-- But Inspect My Plugin Folder. -->
<include-pattern>/cms/wp-content/plugins/myplugin/*</include-pattern>
</ruleset>
Using the example above, I can specify every single folder within the plugins folder except for myplugin and this works, but it is not ideal. (I would have to remember to exclude any new plugin from inspection)
If I remove the exclude-pattern directive, files within the myplugin folder are sniffed, so I know that it is working otherwise.

TLTR; for your specific example:
<exclude-pattern type="relative">^(?!cms/wp-content/plugins/myplugin).+</exclude-pattern>
You can use regex in there but * will be used as .*
Check out this regex with negative lookahead. The type="relative" is important here.
<exclude-pattern type="relative">^(?!plugins/(arve-|advanced-re|edd-)).+</exclude-pattern>

Related

lesscss #import with absolute path

I am having issue trying to refer from a less file another less file using absolute syntax:
Less file A with location
$find `pwd` -name auth0.less
/Users/panos/dcimsupport/struxureon/auth0/src/main/resources/css/auth0.less
imports Less file B
#import '/bootstrap/less/so_colors.less';
Now, the so_colors.less has location
find `pwd` -name so_colors.less
/Users/panos/dcimsupport/struxureon/auth0/src/main/resources/bootstrap/less/so_colors.less
The above fails with
java.io.FileNotFoundException: File /Users/panos/dcimsupport/struxureon/auth0/src/main/resources/css/bootstrap/less/so_colors.less
It seems that lesscss is like jailed to the css folder. I know that if I import as ../bootstrap/.....less it will work but then I have to go as up in directories as required which i'd rather not. Is there some other solution to that? There is limitation though, that bootstrap folder cannot be under css folder
I have used both
<groupId>biz.gabrys.maven.plugins</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
and
<groupId>org.lesscss</groupId>
<artifactId>lesscss-maven-plugin</artifactId>
with configuration such as
<configuration>
<sourceDirectory>${project.basedir}/src/main/resources</sourceDirectory>
<outputDirectory>${project.basedir}/target/classes/resources</outputDirectory>
<compress>true</compress>
<includes>
<include>css/**/*.less</include>
<include>layouts/**/*.less</include>
<include>page/**/*.less</include>
<include>pages/**/*.less</include>
</includes>
How plugins works
The biz.gabrys.maven.plugins plugin treats the path /bootstrap/less/so_colors.less as an absolute. It does not set the sourceDirectory as a root, so it is looking for /bootstrap/less/so_colors.less instead of /Users/panos/dcimsupport/struxureon/auth0/src/main/resources/bootstrap/less/so_colors.less. That file does not exist so the plugin uses fallback and treats it as a relative to /Users/panos/dcimsupport/struxureon/auth0/src/main/resources/css/auth0.less. That is the reason why it is looking for /Users/panos/dcimsupport/struxureon/auth0/src/main/resources/css/bootstrap/less/so_colors.less.
The org.lesscss plugin works similar.
Your idea for improvement
I can try to add such improvement to my plugin, but first I need finish some migration process. Unfortunately this means that I can release that improvement not in the near future (e.g. at the end of 2016).
The org.lesscss plugin is not supported by the author and no one else.
Solution
For now you can only use relative paths with ../.

Why do ../ and ../../ finding the same file?

This is an academic query as I basically have things working two ways but surely one should fail. No? (Sorry I don't know why but I always struggle with paths and this has me flummoxed.)
I have just moved the HTML of three sections out of the main file and am now using an include.
Structure now is:
root - vendor - datepicker - dist -etc- datepicker.css
- beta - main.php
- static - date.inc
In the main.php file I used to have a
<link rel="stylesheet" href="../vendor/
bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css">
When I moved the link up to the .inc file in the static directory (one level up) I thought I should add an extra ../ but was not sure if the css would be called in the new file or in the main.php where the include is called. So I tested both
<link rel="stylesheet" href="../vendor/
bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css">
and
<link rel="stylesheet" href="../../vendor/
bootstrap-datepicker/dist/css/bootstrap-datepicker3.min.css">
BOTH worked. I inspected in chrome and then tried ../../../ and that worked fine too.
I thought the directory form of ../ meant down one from the current level.
To quote on page I just looked at:
Starting with "../" moves one directory backwards and starts there
Starting with "../../" moves two directories backwards and starts there (and so on...)
I realize this is an idiot question and I know I have to sort out proper document paths at some stage but this has me completely confused.
the page you looked at is right ./ means from current working directory, and ../ means go up one directory, ../../ up 2 dir's and so on.. but what happens if 1 directory up is your root folder and you do a ../../? the answer is you'll still be in the root directory, you can only go so far up. this is precisely what happened to you check out your structure, "root - vendor - datepicker" I can elaborate further if you wish. I hope this helps.

How to use a free bootstrap template in meteor

How to use a free bootstrap template (e.g., from startbootstrap.com) in meteor. I mean where the resources- html file, css folders and js folders of the free template should be put and what packages are needed to add/remove in meteor project file? I have tried it several times but got errors and the program crashes each time. I also transfer the script and link tags from section to section, but it did not work.
Just add the css of the template to the client of your Meteor project. Also, try using the nemo64:bootstrap package for Bootstrap. This will add some files to your project automatically, one of which will say is editable at the top. You can put your custom css in that file.
You can put the relevant html, css, and js files anywhere on the client. (Sticking it inside a folder called client will do that).
Image and font files should go in a folder called public.
You will need to make meteor templates from the HTML files. As is they will be missing any <template name="foo"> tags.
The css files can go anywhere under /client and they will automatically be added to the project. These are the easy ones.
The js files are the harder ones. If you put these under /client they will be wrapped by Meteor and will not have global scope. In all probability they won't work at all. You can put them under /public and modify your head.html file to include them to get around that problem. Odds are there won't be very many js functions in the free template anyway so you might want to read through them and see which ones you really need and then convert those to be proper template helpers or global functions on the client.

External CSS style sheet in Eclipse E4 RCP application

How can I specify a non plugin:/... URI as a style sheet location for the org.eclipse.e4.ui.css.swt.theme plugin?
I tried using file://..., to no avail. Relative paths also do not work, as it is assumed they point within the plugin.
The reason behind this is to allow users of the plugin to customize the stylesheet, without having to unpack>modify>repack the JAR application bundle on their own.
Looking at the source of the theme engine if the URI does not start with platform:/plugin/ it is added (with the current plugin id). This is to allow abbreviated URIs but means you can't use any other form.
You can specify that a plugin is not packaged in a jar in the product. If you are using 'features' for the product build specify unpack="true" in the plugin entry in the 'features.xml'
You can also specify
Eclipse-BundleShape: dir
in the plugin's MANIFEST.MF (note this is overridden by the 'unpack' value in the feature.xml if you are using that).

How to include a css stylesheet in Orchard module?

I am working on a module for Orchard, and I just want to know how to include a css file.
I have done the following with no result:
Added a folder "Styles" to the root of my module and included a stylesheet and a Web.config file like in this question.
And I have seen this but that's not what I am looking for.
EDIT:
Ok, solution:
When I started working on Orchard I created a new module by just creating a new project in Orchard.Web/Modules folder, but as I read here, my Views/Web.config file has to include some orchard base things what mine didn't because I did not create the module using codegen. I fixed it now by replacing my Web.config file for a Web.config file from another Orchard module, now it works.
Next time I will use codegen to create a new module.
Thanks to endorphin for helping me!
If you want to include your stylesheet in a view, you need to specify this at the top of your view. Where the name of your stylesheet is the filename of the .css file in the Styles folder.
So in your .cshtml file for your view..
#{
Style.Include("your-stylesheet.css").AtHead();
}
I have used AtHead() in the past, but there are other methods to include your stylesheet in different locations (such as AtFoot())
If your stylesheet depends on other stylesheets you can do something a little more interesting by creating a Resource Manifest which is detailed here https://stackoverflow.com/a/6500121/580101

Resources