I'm working on a Ruby project using RubyMine as my IDE, and I'm utilizing YARD. I'm curious if there's a way to configure RubyMine to restrict commits that contain YARD return type mismatch errors.
Consider the following example:
# @param [Integer] integer input
# @return [String]
def foo(input)
input # This causes a type mismatch
end
In the code above, there's a clear mismatch between the specified return type in the YARD comment and the actual return type of the method.
While I'm aware of RubyMine's ability to display YARD errors in the editor window (as shown in the screenshot below), I haven't found a built-in feature that actively prevents commits if such a type mismatch is detected.
Is there a way to configure RubyMine, perhaps through plugins or external tools, to enforce this check before allowing a commit? If not directly in RubyMine, is there an alternative approach I could use to achieve this functionality?

I'm against both IDE-specific checks, and mandatory pre-commit checks. Here's why...
If you do this in your IDE, then they only work in your particular IDE and only for you. It's better to do this for the whole project.
Pre-commit checks are usually handled by your version control system, but they can get extremely tedious and slow if they're required for every single commit. Furthermore, requiring every commit to pass every test and every code quality check is extremely restrictive; during large or complex refactorings it's often useful to commit even when things are broken.
Is it necessary that every commit be perfect? If you're using a distributed version control system such as Git, commits are local; they only affect you until you push them. A broken commit is not nearly as important as a broken push. Even then, you should always be working in a branch, so a broken branch is also not important. The important moment is when you are merging your branch into the main code; that is when strenuous testing must be done to avoid breaking the code for everyone else.
It's better to do mandatory code quality checks during the branch merge review process (for example, a pull request) and they should be automated. That way everyone's code gets checked.
Simplest thing to do is to add whatever checks you like to your Rakefile, then anyone has the option to make use of them. A single
rake checkcan run all code quality checks. If you like, you can add a pre-commit hook to run your checks before committing, but don't force that on the whole project. Only your branch review process should require these checks.Systems like Github have their own ways to integrate these checks into your review process which you may want to use.