cnescatlab / i-CodeCNES

i-Code CNES is a static code analysis tool to help developpers write code compliant with CNES coding rules.
Eclipse Public License 1.0
62 stars 16 forks source link

IndexOutOfBoundsException while analyzing an empty Shell script #197

Closed begarco closed 4 years ago

begarco commented 4 years ago

Describe the bug i-Code throws an IndexOutOfBoundsException while analyzing an empty Shell script.

To reproduce Run i-Code on an empty Shell file.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots & log

ERROR: Internal i-Code error: exception [IndexOutOfBoundsException] thrown while checking [COM.PRES.Header] on file [/home/begarco/workspace/dotvimconfig/internal/colorscheme/colors/bim.sh] - Index: 0, Size: 0
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.LinkedList.checkElementIndex(LinkedList.java:555)
        at java.util.LinkedList.get(LinkedList.java:476)
        at fr.cnes.icode.shell.rules.COMPRESHeader.raiseErrors(COMPRESHeader.java:330)
        at fr.cnes.icode.shell.rules.COMPRESHeader.run(COMPRESHeader.java:716)
        at fr.cnes.sonar.plugins.icode.check.ICodeSensor.sonarCheck(ICodeSensor.java:273)
        at fr.cnes.sonar.plugins.icode.check.ICodeSensor.executeEmbeddedICode(ICodeSensor.java:193)
        at fr.cnes.sonar.plugins.icode.check.ICodeSensor.execute(ICodeSensor.java:116)

User environment (please complete the following information):

Additional context Run on plugin for SonarQube.