Sonar - Can we use for OSB/BPEL code review? - sonarqube

I am new to sonar,just heard about this tool.
Can we use this tool to perform code review for FMW(Fusion Middleware) -OSB(Oracle Service Bus)/BPEL project ?
If so can anyone give some inputs on this?

The official plugin-List : http://docs.codehaus.org/display/SONAR/Sonar+Plugin+Library/ does not mention support for your tools.
But sonar can be extended with custom plugins, so you may be able to write your own plugins to provide metrics for your tools.

What level of review you want to cover? It is really easy to make your own review tool for BPEL. All BPEL resources are XML files. For example if you want to check for naming convetion of BPEL activities, you can define a simple XPath based rule.
Ex:
//sequence/#name ~= "^sequence.*".
A Java program can use the above XPath to pull-out all sequence names from the xxxx.bpel file and compare it against a regular expression. Similar rules can be created for checking WSDL usage, partner links, end-point addresses, usage of Error handling etc.

Related

What do protofiles represent for googles API Linter?

since google did not create extensive documentation for their API Linter and I cannot find anything from other sources, i wanted to ask here.
From what exactly am i supposed to create protofiles and what do they represent?
As I understood, these protofiles get checked for compliance to their AIPs.
I'm interested in creating a automatic prototype (Java) to check for customized API Rules and am thinking about using Protobufer for this goal. Would this be a pragmatic solution?
Thank you!
As I now understand, Googles API Linter isn't supposed to check a API or a different API specification for compliance.
It checks proto files because they are themself the API specification and can be converted to Code. But before converting them they can be checked against rules they have to comply with.
These rules are not in the protofiles (as I initially thought) but in the many GO-files under rules/ .
Please correct me if you read this and find mistakes! Thanks!

How to plugin into grpc-java to modify code generation and add setNameOrClear(null) methods?

We are having too many issues around all this extra code for every database field with regard to
if(databaseObj.getName() != null)
builder.setName(databaseObj.getName());
and I read square wired into protobuf adding setOrClear methods in java. How do we do this when we generate as well using gradle?
We are using the gradle code from this page right now..
https://github.com/grpc/grpc-java
thanks,
Dean
You can accomplish that via protoc_insertion_points. When you generate the Java code you will see comments like // ##protoc_insertion_point(...). That is where the insertion will occur.
While appearing useful, this approach has serious drawbacks for .protos used in multiple projects. All projects using the same .proto and in the same language should use the same plugins, otherwise it causes the diamond dependency problem. This is why gRPC did not use this approach and instead generates its classes in separate files from the normal message generation. I strongly discourage against this approach, as it paints you into a corner and you don't know when you will need to "pay the piper."
To insert into a point, your plugin needs to run in the same protoc command-line invocation as the java builtin. Your plugin would then need to set CodeGeneratorResponse.file.insertion_point and content for each file you want to inject code.

JavaScript rule extension

I am trying to extend Sonarqube with custom Javascript rules. I find that the documentation is fairly limited on this subject. The extension tutorials on sonarqube website show only the most basic stuff.
The only javadoc I could find is this one: http://javadocs.sonarsource.org/latest/apidocs/ and it doesn't cover anything about extending Javascript.
What I ultimately want to do is add a JS rule that will check for hardcoded secrets (such as passwords, api keys, etc). I already created one for Java, and that was a lot easier as I could take an already pre-made plugin and complete it with my custom regex.
The problematic spot that made me post here was actually this one:
cannot find symbol
symbol: class VariableTree
location: package org.sonar.plugins.javascript.api.tree.expression
I was following the same scheme as with Java and used
import org.sonar.plugins.javascript.api.tree.expression.VariableTree;
which is obviously wrong. I was not able to find the source code for this either... if anybody can point me to some secret doc stash or at least where I can find a javadoc for org.sonar.plugins.javascript.api that would be amazing!
Thanks very much for any help

How to import data to sonarqube database?

I have my own report in a custom format and I want to import it somehow to sonar database to use sonar's widgets to show it. Is it possible in general? Is there any tools to do it?
This will require a custom plugin. Not knowing what type of data you're dealing with, I'll guess that the Generic Test Coverage plugin might be a good model.
You shoud try to do it using the webservice api. That's the recommanded way to do it.
The supported api is self documented on your SQ instance. Here is the API of the nemo instance : http://nemo.sonarqube.org/api_documentation

Google Analytics Reporting API filters/segements

I'm trying to use the Google Analytics Core Reporting API and have the following troubles. I know how to fetch that I want the problem I have is:
I want to use a filter only for specific metrics and not for all of them.
Is this even possible?
Here is an example how my Reporting "Code" looks like:
Metrics "ga:sessions
ga:goal6Completions
ga:goal7Completions
ga:goal10Completions
ga:totalEvents
ga:uniqueEvents"
Dimensions "ga:date"
Filters "ga:eventCategory==customerType"
I have the same problems with segments as with the filters that all metrics all segmented/filtered and only specific metrics should.
There really isn't another way other to get the data you want without creating a new request where the filter isn't applied unfortunately.
Just remember that you are only allowed five requests total. To give context, this may only apply to how I use the Reporting API, but I use Google App Script to push data to Google Sheets.
This may or may not be helpful to you, but the reporting code I use I have made available in a repo on GitHub: https://github.com/jessfeliciano/aggregateGoogleAnalyticsReporting/blob/master/objectQueryWithFilter.js
I've included a guide that gives additional information regarding creating requests in general, so it may spark other ways to go about creating your data trees. I hope this helps.

Resources