Skip to content

Instantly share code, notes, and snippets.

@timurt
Last active August 29, 2017 14:02
GSoC 2017 Report

Timur Tibeyev, Google Summer of Code 2017, Final Report

Project idea:

https://github.com/checkstyle/checkstyle/wiki/Checkstyle-GSoC-2017-Project-Ideas#project-name-flexible-suppression-model

Idea of the project is to propose new suppression model. Checkstyle already has suppression model based on line and column numbers. The main disadvantage of the current model - it is hard to support legacy code. As core developers say: "The only thing that prevents users from using Checkstyle is that it requires huge and unavoidable code refactoring at the beginning". New suppression model should be flexible enough to work with legacy and newly written code. New model should be based on Abstract Syntax Tree. In addition, suppression file generator should be written.

Merged commits:

  1. Add new field to ClassDataAbstractionCoupling, responsible for excluding user-defined classes from check https://github.com/checkstyle/checkstyle/commit/a2b9d0d8a0185e6b3eee83b9f68bfc34bc3a83e7
  2. Move all test files for MethodCount check to separate folder https://github.com/checkstyle/checkstyle/commit/e4e334ebbc3e7f2a3e9b89be19876ab73e34bf85
  3. Add new property illegalClasses to let blacklist certain classes import and add opportunity to use regular expressions for illegal classes and packages for IllegalImport check https://github.com/checkstyle/checkstyle/commit/2f71b27240d2cb3acc5c957d68aa6351b255f89c
  4. Intellij IDEA generates checkstyle.ipr and checkstyle.iws files which are not excluded from checkstyle list, this commit fixes it https://github.com/checkstyle/checkstyle/commit/bb9f0e13eefb36b851b374eda97fbf7a72c7e600
  5. Investigate the ways of using ImportControl check in blacklist mode, add examples and edit documentation https://github.com/checkstyle/checkstyle/commit/48a89f64a72a9d6be62ff5732185b43897492ea4
  6. Add new property to ImportControl, responsible for default strategy in a case, when no suitable allow/disallow rule was found https://github.com/checkstyle/checkstyle/commit/49f684f4af9458fb7e58e11086f49f0bdf2cfc24
  7. Investigate and create new schema for suppression file https://github.com/checkstyle/checkstyle/commit/6f38c1b385ccbfbfbed47bda289c3176bee53f3f
  8. Investigate and create Mapper to map AST elements to Xpath-tree nodes https://github.com/checkstyle/checkstyle/commit/6a323cb521c892c1735350143b5fe2bee1ca8567
  9. Remove dependency of AbstractList from FileText class https://github.com/checkstyle/checkstyle/commit/6091b225584fcf625f136c575139102d20304917
  10. Remove all calls FileText.getLines as it creates copy of the inner array of strings https://github.com/checkstyle/checkstyle/commit/a461e973bf4bf32545aa85b3a8751590d41d340f
  11. Make SuppressionCommentFilter and SuppressWithNearbyCommentFilter children of TreeWalker, as TreeWalker has access to AST https://github.com/checkstyle/checkstyle/commit/63bf86f7d966d221dfe76739c46a1bc41b50f566
  12. Since moving SuppressionCommentFilter and SuppressWithNearbyCommentFilter to TreeWalkerWrite is breaking compability commit, this commit contains gist patches for projects inside wercker.yml https://github.com/checkstyle/checkstyle/commit/d3655517012059a296cdc39939215ef5a40395b1
  13. Remove gist patch for contribution/checkstyle-tester, since checkstyle-tester already supports latest changes https://github.com/checkstyle/checkstyle/commit/7efb8c50a81525d6f98a3d2d457d529770a3a53d
  14. Add new field tokenType to LocalizedMessage class https://github.com/checkstyle/checkstyle/commit/adaf16ac9c45ba3c128053d25efd5eb2861932e9
  15. All usages and mentions of FileContentsHolder should be removed https://github.com/checkstyle/checkstyle/commit/5aaaacea005ef1b8bd3f8e68fdf5881e2b412b1f
  16. Make TreeWalkerFilter recognizable as checkstyle module, update ModuleReflectionUtils https://github.com/checkstyle/checkstyle/commit/9046faddf0a7f5cc7d769aed1bb1c923325d884e
  17. Create xpath query generator based on line and column numbers https://github.com/checkstyle/checkstyle/commit/b183f961fd51a662524ec79c51d88651764f9bcb
  18. Implement Xpath filter https://github.com/checkstyle/checkstyle/commit/06224dbedb4182fa202df05428db38479d638d7c

Proposed commits:

  1. Support suppression-xpath element in SuppressionLoader https://github.com/checkstyle/checkstyle/commit/cb37b393a1c511250e43c38bedadfa0732314fbe
  2. XpathQueryGenerator should consider tabWith parameter https://github.com/checkstyle/checkstyle/commit/c712f78ea0abd6233fb81681b928fd51533adb6e
  3. Add columnCharIndex field to LocalizedMessage https://github.com/checkstyle/checkstyle/commit/176f890ffcd6ab15da1732b9fd8f3a4aa98b5348

Issues which will you plan to do after GSoC and intentions:

  1. Add the new option for Checkstyle CLI to generate the basic suppression xpath (checkstyle/checkstyle#4530)
  2. Generate a suppressions.xml file from the errors list (checkstyle/checkstyle#102)
  3. Extend Checkstyle GUI tool to work with Xpath (checkstyle/checkstyle#4944)

First of all I want to complete my project and continue to improve it. My intentions are to continue contributing to the Checkstyle and other opensource projects. I want to use Checkstyle in my daily developer's life. With new suppression model, it maybe easier to suggest this tool to other developers. I have plans to introduce Checkstyle tool in local meetups and etc.

What I get to know during GSoC:

  1. Maybe the main thing I got to know is Checkstyle tool. Before GSoC I was developing different projects and sometime you need to work with legacy code. It is hard to support and maintain project when written code has no proper class/method/variable namings, no documentation, has complex logic without any explanation. Checkstyle allows you to avoid those problems.
  2. Unit tests, test coverage and mutation tests. During the program, I really understood the price of the good testing. Writing tests for every line of the source code - is something I have never did before. Another interesting thing were mutation tests. During the GSoC I had to run command to check my code using pitest command.
  3. Xpath. What is xpath - xpath uses path expressions to select nodes or node-sets in an XML document. Before GSoC I have heard about xpath, but did not really use it. During GSoC I met closer with this technology, now I understand xpath queries, their meanings and I can construct xpath expressions by myself.
  4. Saxon. Saxon has many features, main features are processors for XSLT, XQuery and XML schema. Saxon library has java NodeInfo interface, implementing this interface allows to query java classes via xpath queries.
  5. Contributing to opensource project, integrating with the community, discussing and resolving issues, working in team with people arount the world.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment