search

Home  >  Q&A  >  body text

java - How to forward code inspection?

The code inspections I know so far are generally done during the continuous integration phase. Although this can ensure code quality, I personally think that the cost is still a bit high. This is mainly reflected in:
It is difficult for a developer to complete the development on his own branch, then push it to the server, and then continuously integrate to check the code and find that the code style is not consistent. Pass, this whole feedback process takes too long.

The Java project currently being developed hopes to be able to check code such as (checkstyle, pmd, etc.). These checks must be passed before submission locally, instead of being done after pushing to the code warehouse. The goals expected to be achieved are as follows:

  1. Must pass code inspection before submission, otherwise submission is not allowed

  2. It is best to have tool support and not rely on IDE

  3. The configuration file of the code inspection tool is best to do version management

Solutions currently thought of (have not tried yet):
Integrate checkstyle and other plug-ins in maven
Use a script in git/hooks to call maven for verification. If the verification passes the submission, if it fails, the submission is not allowed

我想大声告诉你我想大声告诉你2761 days ago934

reply all(3)I'll reply

  • 巴扎黑

    巴扎黑2017-05-31 10:37:13

    It allows developers to push only to a branch that cannot be released (such as dev), and developers of officially released branches (such as master) do not have the right to push directly.

    Install plug-ins such as checkstyle on the server. If the check passes, dev will be merged into the master. If the check fails, the merge will not be allowed.

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-31 10:37:13

    You have understood correctly, git hook is used to do these things

    reply
    0
  • 为情所困

    为情所困2017-05-31 10:37:13

    We use sonar qube to check, and cooperate with jenkins to check during continuous integration.

    It is not required to pass the inspection before submission, because we give developers time to make modifications later.

    Personally, I think that as long as the code can be compiled and unit tests and integration tests have passed, it can be released. Problems found in code inspection can be put into the next version iteration, and the development team leader can just watch the developers make modifications.

    reply
    0
  • Cancelreply