Hi Guys!! Its been a long since my last post. This blog post is intended for all newcomer’s who would like to contribute to coala. So, I will give you an insight into coala’s Structure in a bit detail to actually get you started.
coala’s code base can be found here at github. It’s directory tree looks like:
You can see, this tree has 3 major parts.
api.coala.io
Since, docs
and tests
are established over coalib
, so coalib
is the star directory. And hence, I would be only explaining about it.
coalib
is the collection of various subpackages regarding writing, executing, editing bears, formatting, settings and much more. So let’s dig in boys!!
coalib
is further divided into 11 parts:
aspects
’s API, abstractions
like linter bears and also languages
which contains various language definitions(such as identifying different languages with their versions) to provide unified language experience to coala.LocalBear
and GlobalBear
. Without which bears that exists in coala-bears repo wouldn’t exist.CLI
and at .coafile
.core
module contains the chronological order about what coala has to do with a bear. It takes care of all the step’s involved(like having a complete schedule), when a bear runs over a given file.cachingUtilities
, DictUtilities
, BuildManPage
module and Shell
module. Shell
module is the important aspect here, as it helps coala to run in an interactive shell mode.CLI
. The ConsoleInteraction
module provides the utilities about user provided Actions
like Show_Patch
, Apply_Patch
, Ignore_Patch
..etc. It acts as a mediator between coala and the user, helps coala in providing the user important information by printing generated diff’s, messages, list of bears..etc.parsing
module. It contains all the routines about parsing important information from a string of characters. Most of them support regex pattern matching. For example: Parsing CLI
arguments and creating sections out of it.output
section. results
provides routines like Diff
module, LineDiff
module, TextRange
module and ApplyAction
’s module(user defined actions like ApplyPatch, IgnorePatch, ResultAction and ShowPatchAction). Diff
and LineDiff
modules are similar, they both generates a unified diff corresponding to a generated patch by coala. The only difference between them is LineDiff
generates diffs over two strings wheareas Diff
generates it over two files. When a Diff
is being generated or we have a yielded Result
, it is supplied to the output
section, which in turn is being commuted to the user.setting
in coala consists of a key and a value. It mainly offers many conversions into common data types. It provides important modules like Section
module which holds all the set of settings and ConfigurationGathering
module which plays two important roles:
.coafile
ofcourse)testing
, which contains the API for bear testing. It provides LocalBearTestHelper
module which contains routines like check_results
, check_validity
and verify_local_bear
. These basically test a bear by doing a simple assertion test, between the given result and to the actual yielded result from the bear over a given file.If you will dive deep enough, it’s working is even more interesting. If it sounds interesting to you as well, you can start contributing right away by following our newcomer’s guide.
Till next time see ya!!
Written on May 28th, 2017 by Saurav Singh