Skip to content

Commit 9dcec61

Browse files
Merge pull request #26 from codacy/FT-3627-pylint-issues-not-being-reported
Change message_id and message order
2 parents eb6e70d + b1cfc13 commit 9dcec61

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/main/resources/docs/patterns.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
"level": "Info",
4848
"category": "CodeStyle"
4949
},
50+
{
51+
"patternId": "C0326",
52+
"level": "Info",
53+
"category": "CodeStyle"
54+
},
5055
{
5156
"patternId": "C1001",
5257
"level": "Info",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
##Patterns: C0326
2+
##Info: C0326
3+
def test(name) :
4+
print 'Hello', name
5+
6+
##Info: C0326
7+
def test (name):
8+
print 'Hello', name

src/main/scala/codacy/pylint/Pylint.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,23 @@ object Pylint extends Tool {
4848
val classified = options.get(pythonVersionKey).fold {
4949
classifyFiles(collectedFiles)
5050
} { pythonVersion =>
51-
val validPythonVersion = Option(pythonVersion : JsValue).collect {
51+
val validPythonVersion = Option(pythonVersion: JsValue).collect {
5252
case JsNumber(version) => version
5353
case JsString(version) => Try(version.toInt)
5454
}.map(_.toString).getOrElse(python3)
5555
Try(Map(validPythonVersion -> collectedFiles.toArray))
5656
}
5757
val commands = classified.map { item => buildFileCommands(item) }
5858
val lines_iterable = commands.map { item => item.map(getStdout) }
59-
val lines = lines_iterable.map {
59+
val linesTry: Try[List[String]] = lines_iterable.map {
6060
iterable =>
6161
iterable.flatMap {
6262
item => item.toOption
6363
}.flatten
6464
}
65-
lines.map { line => line.flatMap(parseLine).flatten.filter(isEnabled) }
65+
linesTry.map { line => line.flatMap(parseLine).flatten.filter(isEnabled) }
6666
}
6767

68-
6968
private def parseLine(line: String) = {
7069
val LineRegex = """(.*?)###(\d*?)###(.*?)###(.*?)""".r
7170

@@ -79,19 +78,19 @@ object Pylint extends Tool {
7978
}
8079

8180
line match {
82-
case LineRegex(filename, lineNumber, message, patternId) if message.contains("invalid syntax") =>
81+
case LineRegex(filename, lineNumber, patternId, message) if message.contains("invalid syntax") =>
8382
val fileError = Result.FileError(Source.File(filename),
8483
Option(ErrorMessage(message)))
8584
val issue = createIssue(filename, lineNumber, message, patternId)
8685
Option(List(fileError, issue))
87-
case LineRegex(filename, lineNumber, message, patternId) =>
86+
case LineRegex(filename, lineNumber, patternId, message) =>
8887
Option(List(createIssue(filename, lineNumber, message, patternId)))
8988
case _ =>
9089
Option.empty
9190
}
9291
}
9392

94-
private val msgTemplate = "{path}###{line}###{msg}###{msg_id}"
93+
private val msgTemplate = "{path}###{line}###{msg_id}###{msg}"
9594
private val classifyScript =
9695
s"""
9796
|import os

0 commit comments

Comments
 (0)