Skip to content

IllegalArgumentException: "Invalid range specified" when generating SARIF report #1369

Closed
@mmvpm

Description

@mmvpm

Description

An error java.lang.IllegalArgumentException: Invalid range specified: (60, 59); occurs when generating SARIF reports for classes below.

To Reproduce

There is a class with a method that throws an InvocationTargetException:

public class Main {
    public int invokeDivide(int a, int b) throws
            java.lang.NoSuchMethodException,
            java.lang.reflect.InvocationTargetException,
            java.lang.IllegalAccessException {
        Example example = new Example();
        Method method = Example.class.getMethod("divide", int.class, int.class);
        return (int) method.invoke(example, a, b);
    }
}

And another class in another file:

public class Example {
    public int divide(int a, int b) {
        return a / b;
    }
}
  1. Enable the checkbox "Display detected errors..." in the project settings
  2. Run test generation on the sample class above

Expected behavior

  1. Tests are generated
  2. There are correct links (to places with problems) on the Problem tabs

Actual behavior

java.lang.IllegalArgumentException: Invalid range specified: (60, 59); 
	at com.intellij.openapi.util.TextRange.assertProperRange(TextRange.java:231)
	at com.intellij.openapi.util.TextRange.assertProperRange(TextRange.java:226)
	at com.intellij.openapi.util.TextRange.assertProperRange(TextRange.java:222)
	at com.intellij.openapi.util.TextRange.<init>(TextRange.java:41)
	at com.intellij.openapi.util.TextRange.<init>(TextRange.java:30)
	at org.utbot.intellij.plugin.inspection.UnitTestBotInspectionTool.getTextRange(UnitTestBotInspectionTool.kt:104)
	at org.utbot.intellij.plugin.inspection.UnitTestBotInspectionTool.checkFile(UnitTestBotInspectionTool.kt:54)
	at com.intellij.codeInspection.ex.GlobalInspectionContextImpl.lambda$inspectFile$17(GlobalInspectionContextImpl.java:517)
	at com.intellij.codeInspection.ex.InspectionEventsKt.reportWhenInspectionFinished(inspectionEvents.kt:17)
	at com.intellij.codeInspection.ex.GlobalInspectionContextImpl.lambda$inspectFile$18(GlobalInspectionContextImpl.java:510)
        ...

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions