6

Hopefully this is not to subjective and I know one should not ask "what type of tools" questions, but I need answers :)

Once upon a time I worked on a project for a client where they tested the code when i pushed it to GIT. They tested for CamelBacks, if I used tabs or spaces for indentation and if I commented my functions / classes.

I know they were using Jenkins so I'm guessing they had a hook that was testing my code before it got uploaded.

For front-end we are using HTML, CSS and JS. For back-end we are using Java (and in rare cases .Net C#).

My questions are:

  • What type of testing tool can automatically test this?
  • And is it better to have it as a Jenkins hook or move it down and into the IDE the developer is using?
7

What you are looking for is called static code analysis.

What type of testing tool can automatically test this?

Have a look at this wiki page for a list of tools. One of the most famous tools is SonarQube, which supports Java, JavaScript, C#, and more. It also offers integrations for various build tools and CI servers (including Jenkins). Plus: It is open source.

And is it better to have it as a Jenkins hook or move it down and into the IDE the developer is using?

If you only check on the server side, you would break the build if you commit a style violation you didn't catch locally, since static code analysis tools typically mark builds unstable. And if you only check locally, you may integrate style violations when a developer has a misconfigured IDE. Therefore, you want to have both. That is, some sort of formatter/plugin/… within your IDE which is compliant with your tool's settings and the tool itself that checks everything that is pushed to the repository.

|improve this answer|||||
2

It depends on the language you are using, personally, I use StyleCop for C#.

But for some people, StyleCop is a bit overkill as it applies a very comprehensive and strict set of rules.

I think it is better to have a syntax checking tool integrated with the IDE you are using as the sooner you start the better. When you push it to Jenkins, it may be kind of late and the effort for you to correct mistakes will be increased.

|improve this answer|||||
  • The problem, as I see it, is that by having it in the IDE it might not be consistent in use. Not everyone installs it and not everyone might have configured it correctly. – Steven Feb 19 '18 at 19:34
  • @Steven, very good point, you will need to coordinate among developers to agree on a coding standard. – Yu Zhang Feb 19 '18 at 19:42
  • 1
    But even before you can coordinate, you need first to detect that some IDE is misconfigured. So you need to run the same rules on server, as @beatngu13 suggests – Peter M. - stands for Monica Feb 20 '18 at 14:44
  • @PeterMasiar, I agree. I was not aware of this tool, SonarQube. Thank you for pointing this out. – Yu Zhang Feb 20 '18 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.