I'm using CodeClimate version 0.70.3
When running the linter on a ruby file, I got this error on the console
[Linter] Error running Code Climate TypeError: Cannot convert undefined or null to object
After some investigation, the root cause was this line in index.js file.
It's trying to access issue.location, but the issue object has no location key.
That's the output of running codeclimate -f json /path/to/file.rb
[
{
"name":"ruby.parse.succeeded",
"type":"measurement",
"value":1,
"engine_name":"structure"
},
{
"type":"Issue",
"check_name":"sql_injection",
"description":"Possible SQL injection",
"fingerprint":"...",
"categories":[
"Security"
],
"severity":"minor",
"remediation_points":300000,
"location":{
"path":"/path/to/file.rb",
"lines":{
"begin":23,
"end":23
}
},
"content":{
"body":"..."
},
"engine_name":"brakeman"
},
{
"type":"Issue",
"check_name":"Rubocop/Metrics/CyclomaticComplexity",
"description":"Cyclomatic complexity for load_resources is too high. [8/6]",
"categories":[
"Complexity"
],
"remediation_points":1140000,
"location":{
"path":"/path/to/file.rb",
"positions":{
"begin":{
"column":3,
"line":107
},
"end":{
"column":6,
"line":114
}
}
},
"content":{
"body":"..."
},
"fingerprint":"...",
"engine_name":"rubocop",
"severity":"minor"
}
]
You can notice that the first element in the output is of type measurments not Issue, this has been recently introduced in codeclimate json formatter.
So as a quick solution, I just added this condition inside the forEach block
if (issue.type !== 'Issue') {
return;
}
We may also filter the messages before calling forEach.
Do you have a specific guide to create a pull request with this fix?