Code sharing: Builder/LibIDE/coala
@sils
Submitted by Lasse Schuirmann Link to original bug (#744350)
Description
Hello,
I'm a main developer of coala. coala is meant as a static code analysis framework and currently not a GNOME application.
https://github.com/coala-analyzer/coala
However in order to realize coala we had to implement some features Builder or LibIDE has or will have.
If coala is installed it installs its library which contains all the features described below into the python installation directory.
This bug is a proposal to try to reduce code duplication between those three/two projects. coala is still in an early but functional state so big changes to our architecture are possible if it makes sense and saves work for the sum of the involved projects. (I'm not interested in me having not much to do but in reducing the double work.) I'd also be happy to move some features out of coala to some external library if the library tries to maintain platform independence and does not yield huge other dependencies.
This is possible for a few features IMO, namely:
Project files
coala has an own parser (and writer) for project files which are similar to the editorconfig format. This file format allows specifying arbitrary settings grouped in arbitrary sections.
Files are specified via recursive globs which is a very intuitive thing to do for the user IMO.
As mentioned coala also supports writing project files which is cool because you can generate it from a command line invocation and ask users for missing bits.
This is fully implemented and completely unit tested available in coala. We did put a lot of thought into this format and those parsers so I think its worth sharing.
Language Definitions
Builder seems to have all its definitions for languages in one file, namely: https://git.gnome.org/browse/gnome-builder/tree/src/resources/language/defaults.ini
As we have those parsers mentioned under Project Files, coala will probably support some very similar language definition file format in the near future. Furthermore coala will also ship some default language definitions similar to the one in your ini file.
In joining our efforts we could be able to provide our users better and more language definitions while creating a simple and intuitive common file format.
See https://github.com/coala-analyzer/coala/issues/250
This feature is not yet implemented but shouldn't be hard to do.
Settings Autodetection
I do not know if such a thing is planned for Builder but IMO it is way easier if the editor autodetects the codestyle (tab/spaces, number of spaces, ...).
To ease the configuration of coala I am currently planning such a feature for coala.
See https://github.com/coala-analyzer/coala/issues/251
Fix-Its
IIRC Builder will use clang for live code checking. coala currently supports code checking and code replacements in a sequential workflow. (Which we hope to fix soon.) However the main point and idea of coala is to put an abstraction between the user (which could be a human or Builder) and the code checking routines (like clang invokations).
What I'm trying to say is that ultimately Builder could instead of invoking some language specific clang API invoke coala and let coala invoke clang and maybe for some other languages some custom routines.
In the end Builder will get a result which is converted to one unified result type. We are already providing Annotations and Replacements.
Currently we have a few commits in review that will allow setting dependencies so an AST could be reused for checks from different sources. Caching is on our list too.
However note that this probably is a performance overhead over directly invoking clang due to all those abstractions.
coala's IDE support is currently in planning stage. See: https://github.com/coala-analyzer/coala/wiki/Project-Ideas#ideoutputter
Last and least coala could provide static code analysis features which could ease developing builder. Currently this is limited to searching for keywords, checking line length and automatically correcting spacing issues (tabs <->
spaces, trailing whitespace). I will probably do my bachelor thesis about code duplication detection which will be almost language independent, so hopefully easily adjustable.
Those are still simple things but you won't believe me how often I and others had to rebase one of my patches for last GSoC for spacing issues which coala can correct automatically. (More relevant for newcomers.)
Many greetings,
Lasse Schuirmann