How to specify SonarQube rule description as a markdown/html resource file instead of using annotation? - plugins

I have my custom rule, let's say with AEM-1 key. So, as it is done here, I make my AEM-1.html resource file with some simple html content and it does not get's picked up by SonarQube 5.1. It refuses to start, because no description is provided for the rule.
I tried different packages names, tried to look for convention in source code etc. What's missing? Is there any documentation on that?

The naming convention is org/sonar/l10n/{plugin key}_{language}/rules/{repository key}/{rule key}.html.
It was documented in http://docs.sonarqube.org/display/DEV/Internationalization at the time rule descriptions supported localization. That's not the case anymore since version 4.2, but these HTML bundles are still supported.
The correct way since version 4.3 is to use the low-level API org.sonar.api.server.rule.RulesDefinition. It allows you to implement any kind over layer over it (xml, json, annotations, ...).

Related

Simple API call within the context of DocFx preprocessor

I would like to know if it is possible to make a simple API call (e.g. GitHub API v3) within the context of a DocFx custom template preprocessor. I have been trying all sorts of different approaches, but nothing has fully worked so far.
My goal is to make a call to an API to retrieve some data, and then update the model accordingly to be used in the *.liquid or *.tmpl renderers.
I have tried using the http/https node modules. I have also tried using node-fetch. It results in a docfx build error something like:
Error:Error transforming model ".../index.raw.json" generated from
".../index.md" using "conceptual.html.primary.js". Error running
Transform function inside template preprocessor
According to DocFx documentation, preprocessors follow the ES 5.1 standard. My code conforms to this.
Does anyone know if this is possible?
By the way, I am able to do simple model manipulation just fine, so I understand the basic concepts here with the DocFx preprocessors.
Thanks!
For the benefit of others, I discovered DocFX uses jint which cannot require a Node library directly. Therefore, it appears the plugin route is a better way to go for this use case.

Configure Swagger api with Play 2.4

Facing problem while configuring swagger api with play 2.4 framework.
Follow this url for configuration : https://github.com/swagger-api/swagger-play/tree/master/play-2.4/swagger-play2
After configuration gets a compile time error with message "type ApiHelpController is not a member of package controllers" as this ApiHelpController.scala file is present in app/controllers package.
Does anyone knows what i am missing.
Not sure what you are missing but let me show you an alternative for swagger play 2.4 integration
Unlike the one you were trying to use, this one does not require annotation, you write swagger spec directly in your routes files as comment. There are several benefits of this approach:
controller remain clean
you don't need to repeat path and parameters
you don't need to learn another API (the annotation api)
Also it generates swagger definition from case classes reflection.
Check it out:
https://github.com/iheartradio/play-swagger
Not sure about swagger-jaxrs, but swagger-play2 package works for me. You can refer to http://swagger.io/playing-with-swagger-using-swagger-and-swagger-ui-with-the-play-framework/

Not able to call form in AEM6

I have copied the Forms from the /libs/foundation/components/form to /apps/mywebsite/components/form, I made some changes to the copied form files but still the default form is getting called.
Could you let me know or provide some documentation for the forms.
Thanks in advance
The problem is that you moved things to:
/apps/mywebsite/components/form
Instead, you need to copy them to:
/apps/foundation/components/form
apps overrides libs ONLY if the path is otherwise the same
so:
/apps/something/something/somethingelse
will override:
/libs/something/something/somethingelse
if ANY part of that path is different, that overlay won't work.
In addition, if something calls a component/resource/whatever under /libs using the fully qualified name (e.g. actually including /libs/ at the beginning) then it will still use that. But this is rare.
Let me know if you have more issues.
BTW, you can change this search approach (apps before libs) in the resource resolver settings in OSGI. It comes this way by default but can be changed.
If you didn't want to overrride but extend the foundation forms, you need to make sure that you copied everything or have the inheritance to foundation right. Most important is the cq:editConfig/cq:formParameters, where you need to have sling:resourceSuperType="foundation/components/form/defaults/field". If you use a cq:template instead, you need to set the supertype parameter there.
Then you would have to use your components on the page instead of the foundation ones.

TypoScript: Check if JS/CSS File is already included

anybody knows how to check if a js/css file is already included with typoscript?
Example
[Template_A.ts]
page.includeJS {
jsfile = fileadmin/Template/js/jquery-1.10.2.min.js
}
now if i got an extension with the same include e.g.
[Extension_A.ts]
page.includeJS {
jsfile = fileadmin/Template/js/jquery-1.10.2.min.js
}
Is there a way to prevent this kind of double code injection? Maybe i got another Template e.g. Template_B.ts where jquery is not included - than the Extension_A.ts has to include jquery by itself.
Kinldy
You can use the same key inside includeJS such it just gets overridden if you include the file twice.
Other than that you should put jQuery into includeJSlibs, such that it is loaded before the other JS files.
Other than that, the TS should be unique for each page. Therefore you always to make sure anyway that all resources are included in-order.
You should not include JS libs with the automatic extension TS setups. Use your documentation to tell the integrator what needs to be included and what not.
The various and independent inclusion of scripts by plugins and templates is one of the tricky points in TYPO3. As far as I know, this point cannot be managed at one single point.
There is a plugin "t3jquery" that offers to build, compress and share a common jQuery library. It also has a service to analyze other plugins for their dependencies. But this doesn't solve the problem in general, as many plugins don't check for libraries already loaded.
The most stable way is to remove all plugin's references to libraries manually in your TypoSkript. This gives you some simple additional TypoSkript lines. I use lines like these:
plugin.tx_imagecycle_pi1.file.jQueryLibrary >
plugin.tx_imagecycle_pi1.jQueryLibrary >
plugin.tx_multicontent_pi1.file.jQueryLibrary >
plugin.tx_multicontent_pi1.jQueryLibrary >
# Fluid
page.headerData.998 >
You can find the matching TypoSkript descriptors by searching for the library name in the TypoSkript browser or by greping in the plugin's source code. You will also need this if you wish to add libraries as part of content that was get by AJAX, thus separating the libs from the page content.
Here's a tut (in German): http://jweiland.net/typo3/typoscript/javascript-manuell-entfernen-oder-einbinden.html
Futher possibilities you can check:
Some plugins are written in good structure and offer to keep back their Javascript in the settings.
Some script inclusions may come rather from the static template but from a plugin, so don't forget to have a look there.

Unicode normalization in GWT [duplicate]

I tried
s=Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", "");
But it seems that GWT API doesn't provide such fonction.
I tried also :
s=s.replace("é",e);
But it doesn't work either
The scenario is I'am trying to générate token from the clicked Widget's text for the history management
You can take ASCII folding filter from Lucene and add to your project. You can just take foldToASCII() method from ASCIIFoldingFilter (the method does not have any dependencies). There is also a patch in Jira that has a full class for that without any dependencies - see here. It should be compiled by GWT without any problems. License should be also OK, since it is Apache License, but don't quote me on it - you should ask a real lawyer.
#okrasz, the foldToASCII() worked but I found a shorter one Transform a String to URL standard String in Java