Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out of bounds exception on empty files #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simonbrandhof
Copy link
Contributor

See initial pull request : #9
Unit test has been added.

ThE-TiGeR and others added 2 commits August 14, 2018 22:44
INFO: java.lang.ArrayIndexOutOfBoundsException: -1
INFO: at java.util.ArrayList.elementData(Unknown Source)
INFO: at java.util.ArrayList.get(Unknown Source)
INFO: at org.sonar.plugins.scm.mercurial.MercurialBlameCommand.blame(MercurialBlameCommand.java:104)
INFO: at org.sonar.plugins.scm.mercurial.MercurialBlameCommand.access$000(MercurialBlameCommand.java:42)
INFO: at org.sonar.plugins.scm.mercurial.MercurialBlameCommand$1.call(MercurialBlameCommand.java:83)
INFO: at org.sonar.plugins.scm.mercurial.MercurialBlameCommand$1.call(MercurialBlameCommand.java:80)

This happens if blame fails (e.g.) file not under version control and the source file has only one line of code
CommandExecutor commandExecutor = mock(CommandExecutor.class);

when(commandExecutor.execute(any(), any(), any(), anyLong())).thenAnswer((Answer<Integer>) invocation -> {
// Hg doesn't blame last empty line
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the comment // SONARPLUGINS-3097 Mercurial do not report blame on last empty line already exists, is there a need for both? If so is the behaviour better described in a docstring instead of inline comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants