I have read through the complexity documentation via SonarQube Metrics Definition. I have also dug through the Rules we have defined, but those only determine bugs in the code & their respective severity. Unfortunately it does not outline how we could go about defining custom complexity rules (i.e. if you do x, the complexity will be increased by 1).
Could anyone shed some light on this?
Your question didn't originally specify language, so for
Java - Writing Custom Java Rules 101.
JavaScript - Custom Rules for SonarJS
PHP - Custom Rules for PHP
COBOL - Custom rules for COBOL
These are brief tutorials to bootstrap rule writing. In writing your own rules, you'll likely have questions of the "How do I get to X?" nature. With those, you should open a new thread on the SonarQube Google Group.
On https://docs.sonarqube.org/display/PLUG/Custom+Rules+for+SonarJS, it says
Custom rules
This feature is deprecated
As a replacement, we suggest you to have a look at ESLint, it provides custom rules that you can then import thanks to the External Issues feature.
Related
i have been using slim 3 and finally got my head around psr-7. Now working with laravel i see that out of the box, psr-7 is not supported.
Now... is there a strong reason to follow psr-7 or the laravel request styles?
personal preference for example, is not a strong reason.
I just don't want to code entire apps with laravel request classes, that is Illuminate\Http\Request just to find out in a year that I really should have followed the psr-7 standard.
Short Answer: No
Long Answer:
Consider the purpose of PSR (PHP Standard Recommendations) and how much it means to you that every facet of your chosen framework follows these standards.
Laravel doesn't come with PSR-7 supported out of the box, because the Symfony Component on which its Request/Response system is built is not PSR-7 compliant either. In fact, this component is often found at the heart of MANY frameworks and was written at a time before the idea of PSR caught on.
In order for Laravel - or any other frameworks that depend on this component - to become PSR-7 compliant, it will have to change its dependency on the Symfony HTTP Foundation component to something else, or perhaps even roll its own implementation.
Remember, ALL PSR recommendations are just that: Recommendations.
None of them are required.
Their sole purpose is to help unify the writing of PHP into more predictable formats so that all PHP devs who are at least familiar with those standards will be able to then follow and more easily understand each codebase that complies.
There is no compelling reason to refactor any codebase or framework of reasonable complexity to be PSR-compliant just for the sake of it
As you yourself said, personal preference is not a strong enough reason to overhaul a codebase.
As for your use-case, you need to ask yourself what a PSR-7 compliant framework will achieve for you over a non-compliant one. The issue isn't one of maintainability, as PSR-compliant code is no more - or no less - maintainable than non-compliant code.
If you're writing an API in which you'll need total control over the Request/Response lifecycle, then perhaps a PSR-7 compliant framework like Slim would be best to use. If you're writing a general-purpose application in which the only requests and responses you'll concern yourself with are a handful of AJAX and JSON routes, then you're probably fine with Laravel or Lumen.
Don't get caught up too much in whether or not a given framework complies with the FIG. Just do your research, and make sure that the toolset you choose best suits your needs.
I really like the way Algolia has approached their multi-programming language API documentation, e.g. https://www.algolia.com/doc/javascript .
Does some know by chance what technologies do they use to generate it?
The documentation generator we're using is currently an internal tool. We might open-source it at some point, but it would require some extra work time which we don't currently have.
It's basically a markdown file with some extra syntax to:
handle multiple languages code blocks (it then automatically selects the good one)
handle conditions depending on the current language
handle callouts
handle buttons
The rendering is then hand-made with the help of bootstrap.
I would like to add a Sonar rule to forbid use of URL GET parameters.
I mean I only want to allow POST parameters in my application forms.
Can you help me to write this rule ?
Since the Web plugin doesn't support custom rules, you'll need to either write your own supplementary plugin (i.e. use the Web plugin plus the one providing your custom rule(s)) or submit a pull request to add your rule directly to the plugin. In either of those cases, you should probably look to the SonarQube Google Group for further discussion/guidance.
You didn't specify the language you want to analyse, but depending on which one you're using you can use XPath to analyse the syntax tree. If XPath isn't supported for your language you'll really have to write your own custom plugin like said in the other answer.
See here for each language support:
SonarDocs - Writing Custom Rules
If you do need to write a custom plugin, I can only recommend you to take a look at the existing code, starting with java.custom-rules
Using codeigniter 2. Don't want to reinvent the wheel. Have tried Grocery_CRUD and found it takes as long, or longer, to learn it that it did to learn codeigniter.
Looking for crud library that makes sense, easy to learn so I don't reinvent the wheel.
Many thanks for any ideas.
You can use http://www.grocerycrud.com
It's easy to use with codeigniter.
Sample use
$this->grocery_crud->set_table('customers');
$this->grocery_crud->columns('customerName','phone','addressLine1','creditLimit');
$this->grocery_crud->render();
Also you can take look at https://github.com/jamierumbelow/codeigniter-base-model
This is very basic base model class for CI
Subjective but take a look at https://github.com/keevitaja/simple-crud-codeigniter
Why don't you try MY_Model to do all the CRUD functionality?
MY_Model
Just want to inform all you that I have released CRUDDER. This is a plug-in module for your application that works as a CRUD solution, ideal for systems back-ends.
CRUDDER is developed using CodeIgniter and Bootstrap for look&feel. You can develop your own skin appart from the Bootstrapped one. Full localization is possible. CRUDDER is designed to be intuitive and easy to use. The interfaces always show on-line help tips related to the CRUDDER itself and also to your database characteristics.
I'm attaching here an image of the CRUDDER example contained in the product web page so you can figure how easy it's to use.
On the other hand, you will find that configuration is very easy. There is no need to write code other than your own custom validation rules (more powerful than the CodeIgniter ones). There are only two classes: one contains all the functionality code and the other, Crudderconfig, encapsulates the configuration and localization parameters.
In contrast to other commonly used open-source CRUD solutions available, in CRUDDER all the table-and-field-specific metadata don't require to write code. All of this is contained in two "metatables", that can also be managed using the CRUDDER itself... so you use the CRUDDER to create your own CRUD rules (don't need to use phpMyAdmin, for example). This is a plus for users seeking for simplicity.
A full list of features is available:
Open the project web page
Among them:
Pluggable to applications not developed with CodeIgniter.
Sort, filter and pagination features, among others.
Soft deletes with unique-index collision avoidance.
Automatic menu-type form fields based on other tables content.
Extensible event triggering when a value is changed in a form.
Interface help tips for fields are contained in the database.
Designed with strong security in mind.
Take a look! Write me if you like it, have questions or want another functionality.
CRUDDER is released under the GNU LGPL license.
I have been fiddling with SONAR for some time now, and I would like to extend it to some point. I don't think I will be able to achieve this with a custom plugin but if I would introduce an additional controller and some views - it would get the job done.
Now as I understand, MVC model in sonar is written in RUBY, and I have yet to do research on ruby coding, but before I get to that - is my goal reasonable/achievable ?
Or can additional views and controllers can be added via plugin extensions ?
Basically I just need certain information gathered from sonar DataBase about the project, and displayed in a custom view for additional statistics.
Thanks.
P.S. I have hard time finding information for sonar development, maybe someone could recommend some forums discussing sonar extension topics ?
It is not possible yet to add Ruby controllers and views at the same time through a Sonar plugin. Currently, when extending Sonar Web interface, you can only:
Add a Ruby widget (that will be displayed on a dashboard): this is only a view
Add a Ruby web service API: this is only a controller
Add a GWT extension: here you can define a controller and a view
However, please note that we will drop GWT support in the future, and replace it with the possibility to define extension points that allow to write both controllers and views in Ruby.
So to answer your need, I would advise you to write a widget, like the ones you can see on Sonar source code here: https://github.com/SonarSource/sonar/tree/master/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets
HTH