How to disable pre-commit code analysis for Git-backed projects using IntelliJ IDEA

懵懂的女人 提交于 2019-12-20 11:04:26

问题


I have a project in IntelliJ IDEA, and I'm using Git/GitHub as source control. Each time I try to commit changes, IntelliJ IDEA runs a lengthy code analysis and searches for TODOs. When it finds "problems," it prompts me whether or not I want to review or commit.

I don't want the pre-commit code analysis to run, and I don't want IntelliJ IDEA to ask me about the results. I can't seem to find any setting in the regular IntelliJ IDEA project/IDE settings to disable this. How can I disable this?


回答1:


Answer for IntelliJ IDEA 11.1.5:

There are persistent check-boxes in the "Commit Changes" dialog. The next time you go to commit a changelist, uncheck the "Perform code analysis" and "Check TODO" check-boxes.

If you want to just get it done now:

  • Make a non-invasive, 'test change' to a file; for example, add a test comment to any file
  • Right click on the changelist and select "Commit Changes..."
  • In the "Commit Changes" dialog, uncheck the "Perform code analysis" and "Check TODO" check-boxes
  • Click "Commit" to persist the settings. You can then undo the test comment and commit that.

I can't find anyway to disable these checkboxes by default for new projects.




回答2:


The following is perhaps a simpler (albeit, a bit more hacky way) to do this. This involves making a simple edit to a file and, depending on the file you edit, result in the checkboxes being unchecked by default either for an existing project (A) or result in those checkboxes being disabled by default for ALL new projects (B).

This has been tested on IntelliJ IDEA version 2016.3

(A) Project Level Change

(This should be used for existing projects, where you are sick of disabling either of the checkboxes for every commit.)

To have those two check boxes disabled by default for a specific project, in .idea/workspace.xml add the following two options under the component called VcsManagerConfiguration:

<component name="VcsManagerConfiguration">
    <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
    <option name="CHECK_NEW_TODO" value="false" />

The option names are self-explanatory (the former is for disabling Perform Code Analysis and the latter for disabling Check TODO).

Note that the effect is immediate. You don't have to restart IntelliJ IDEA or reopen the project



(B) IDE Level change - Will affect all new projects

(This should do that by default. The checkboxes will be disabled for any new projects.)

If you make the same change, i.e. adding the two options as below to VcsManagerConfiguration, to the file project.default.xml (location of this file is detailed in the next section for the major OSes) then this will get inherited by ALL new projects and you will be rid of this annoyance for good until an update of IntelliJ IDEA changes how these settings are stored :)

<component name="VcsManagerConfiguration">
    <option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
    <option name="CHECK_NEW_TODO" value="false" />

Location of project.default.xml

(Based on Directories used by the IDE to store settings.) (I have only verified the OS X path. The remaining are based on the link above and are not verified.)

Mac OS X: /Users/az/Library/Preferences/IntelliJIdea2016.3/options/project.default.xml

Windows: c:\Users\John\.IntelliJIdea2016.3\config\options\project.default.xml

Linux: ~/.IntelliJIdea2016.3/config/options/project.default.xml



来源:https://stackoverflow.com/questions/16369749/how-to-disable-pre-commit-code-analysis-for-git-backed-projects-using-intellij-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!