3

I've started working with jHipster on a recent project which is a tool you can use to autogenerate the full stack of a REST api application using a Spring Boot back end. Which should save a great deal of time writing boilerplate code...

Unfortunately, at my work we have coding standards to adhere to in the form of a set of CheckStyle rules. Any code that does not adhere to these rules causes the build to fail. What I am experiencing at the moment is that this autogenerated code is failing the CheckStyle rules in a large number of places. Currently I am handling this by manually trawling through the code fixing each of the issues.

I can't help feeling in the back of my mind there must be a better way of doing this e.g.:

  • Configuring the IDE (intelliJ) to ensure the generated code matches the CheckStyle rules. This is certainly possible when coding directly into the IDE.
  • Configuring jHipster to be aware of the CheckStyle rules before autogenerating the code.
  • Running a script afterwards which can automatically fix any CheckStyle failures. (I'm sure this must be doable!)

It would be good to hear if anyone knows what the best way to address this issue might be and if anyone has done something similar in the past.

Plog
  • 9,164
  • 5
  • 41
  • 66

1 Answers1

3

Suppress violations on all auto-generated files as it is out of your control.
http://checkstyle.sourceforge.net/config_filters.html#SuppressionFilter

If you have auto-generated code inside a file with non-generated code that you maintain manually, use comment suppressions.
http://checkstyle.sourceforge.net/config_filters.html#SuppressionCommentFilter

You shouldn't be styling code you don't write for this exact purpose, you aren't writing it and some utility is and it wasn't built to your style specifications. If you generate the files again, it will undo any manual changes you made.

rveach
  • 2,081
  • 15
  • 25
  • Thanks for the reply. This is definitely something I was considering and I agree with you. I will try raise this in our next sprint retrospective to see if I can convince my colleagues. – Plog Jul 25 '17 at 15:22