Google Summer of Code 2019 Work Product Submission



coala

Naveen Naidu

I’m a final year student (expected graduation date: Aug 2020) of Computer Science at PES University - ECC Campus, India. I participated in GSoC and worked with coala to implement the support to handle nested programming languages. I laid out and implemented the entire architecture for coala to handle most of combinations of nested languages.


Patches Tarball

Bonding

Phase 1

Phase 2

Phase 3


Repository Link to Commit/s Description
c  cEPs View

cEP-033: Handle Nested Programming Languages

c  coala View

Implement NlSection

c  coala View

Implement NlSectionPosition

c  coala View

Implement Parser Base Class

c  coala View

Implement PyJinjaParser

c  coala View

test-requirements.txt: Add regex module

c  coala View

DefaultArgumentParser.py: Add nested language mode support

c  coala View

TestUtilities.py: Add PEP8TestBear, Jinja2TestBear

c  coala View

NlInfoExtractor: Add NlInfoExtractor

c  coala View

NlFileHandler: Add NlFileHandler

c  coala View

NlCliParsing: Add NlCliParsing

c  coala View

Implement NlCore

c  coala View

coala_main: Add support for nested language mode

c  coala View

ConsoleInteraction: Add support for nested language mode

c  coala View

Processing.py: Add support for nested language mode

c  coala View

ConfigurationGathering: Add support for nested language mode

c  coala View

result_action: Add support for nested language mode


Handle Nested Programming Languages

Work Done

  • coala now has a nested language mode. It allows coala to lint through the files that have a combination of nested languages and provided patches to the user, just like how it’s done in the normal mode.

  • The vast majority of my project was based on laying down the architecuture to make this project possible. And hence, I only implemented the support for the files that have Python and Jinja2 as the combination. That being said, extending the support for other languages is really easy.

  • The user can switch on nested language mode using:
    coala --handle-nested --languages=python,jinja2 --files=test.py.jj2
    --bears=PEP8Bear,Jinja2Bear,SpaceConsistencyBear
    
  • The argument --handle-nested is used to specify that the files has a combination of nested languages. The argument --languages is to mention the languages that exists in the files. Note that, it is important to mention the --languages argument since coala cannot auto detect the languages present in the nested language file.

  • Also special care has been taken to keep the signicficant part of the core coala untounched by my implementation. No major changes have been done to the way coala works. This would help as this is still an experimental features and many changes are yet to come.

  • An asciinema of the working is here

Challenges

  • The most challenging part of the project was to come up with a proper architecuture that would work. I must confess that I put in more than 2 month of time before GSoC to try out various possibilites that might make this project a reality. I am grateful to all the mentors of coala who kept reviewing my various approaches even with their busy schedule, without their insights I would never have been able to finalise on my proposal.

  • Since this project deals with the core of the coala, I was pretty scared to get into the waters of the huge codebase. But with the constant support of mentors and as the time went on, I was about to understand how the different components of coala actually pieced together.

  • Another difficult situation that I faced was during my Third Phase of GSoC. The approach I planned out for the assembling of the files did not seem to work. So I was supposed to come with a new approach in a span of 11 days. I was pretty pissed and scared ,but apparently it took lesser time than i expected, this taught me not overestimate the time and take things one at a time.

  • And last not the least was about maintaining the coverage while implementing the details. It took me time to soak in all the coverage, but it all turned out to be good.

  • The entire experience was really fun, though at times there were few hair plucking moment but this taught me a lot about how the architectures need to be made and how different components needs to be designed to keep track of scalability.

Work to be done

  • I’ve complete almost all of the goals that I had planned out for this GSoC. But there are a lot’s of enhancements that can be done to the way of how Nested Language mode can work.

The work to be done is:

  1. Enhance the way how parsing is done. For now it supports most of the cases, but there are few edge cases that I might have missed.
  2. Add parsers for other combination os the languages.
  3. Add support to enable nested language mode from .coafile
  4. For now, when we have a line with mixed language, we pass off the mixed language line to a bear that can handle both the languages. This needs to be changed.
  5. A way to make coala ignore the position markers that are added in NlFileHandler to extract the sections after linting. The changed needs to be made in ignore_ranges of Processing.py. I’m guessing that we might have to change the way how ignore_ranges work.