Code inspection on files using git diff or custom files list

Code inspection is a good tool for code reviews. My goal is to run inspection only on files which was changed between branches or/and different commits. Probably there is no such option in IDE however I can make a list using git diff from my repository with file's paths like for example:

application/classes/Controller/Account.php
application/classes/Controller/Bookings.php

Now I would like to paste somewhere such list or select these files automatically to run inspection only on them. Is there any way to do that?

1

You can switch to "Changed files" scope and run inspection right clicking the top folder:

0

I tried that, however for IDE none of files were changed, because I didn't change them. 2-3 my co-workers worked on their feature branches. They pushed they work to developer and finally we created release branch. So I checked out release branch, run changed files scope and it found 0 files / errors. When I opened all files manually  and used "open files" scope it worked. By "worked" I mean it found warnigns in modified files, which I opened.

Should I create some change list from branch like master, than checkout to my release branch and now should it work?

 

0

Oh, I got it. Yup, "changed files" would show no files there.

In that case you could indeed create a list using git diff & after that use some editor to create following line which you can then use in "Scopes" to create a custom scope:

file:application/classes/Controller/Account.php||file:application/classes/Controller/Bookings.php

 

Like this:

 

You can then run inspection against that scope

 

2

Oh, forgot to add: the originally requested feature isn't yet supported out of the box: https://youtrack.jetbrains.com/issue/IDEA-145053

0

Great. I was trying to use pattern, but didn't know that I need to type "file" before path. BTW: Do you know if is there any limit to the pattern string? Because files list may be quite long sometimes.

Thank you for link to the issue. I will watch changes, however this solution with pattern is very enough for me right now.

 

0

No, unfortunately I don't know if there's a limit on a string. You might want to include entire folders to workaround that. That would look like:

file[projectname]:application/classes/Controller/*||file:application/classes/Controller/Bookings.php

You can play around with syntax in File | Settings | Appearance & Behavior | Scopes.

0

You can run on console `git reset --soft master` and then you have all the changes to master branch as changed files and can run analyze on changed files.

1

请先登录再写评论。