mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-08-12 09:22:50 +00:00
(#15115) [linter] reduce pylint to just one command
* determine test_package folder in the lint rule * delete old test specific linter config + update github workflow * fixup: put bad specific config --------- Co-authored-by: Chris Mc <christopherm@jfrog.com> Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from pylint.checkers import BaseChecker
|
||||
from pylint.interfaces import IAstroidChecker
|
||||
from astroid import nodes, Const, AssignName
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class PackageName(BaseChecker):
|
||||
@@ -21,10 +22,18 @@ class PackageName(BaseChecker):
|
||||
"Missing name attribute",
|
||||
"conan-missing-name",
|
||||
"The member attribute `name` must be declared: `name = 'foobar'`."
|
||||
)
|
||||
),
|
||||
"E9007": (
|
||||
"No 'name' attribute in test_package conanfile",
|
||||
"conan-test-no-name",
|
||||
"No 'name' attribute in test_package conanfile."
|
||||
),
|
||||
}
|
||||
|
||||
def visit_classdef(self, node: nodes) -> None:
|
||||
filename = Path(node.root().file)
|
||||
is_test = filename.match('test_package/*.py') or filename.match('test_v1_package/*.py')
|
||||
|
||||
if node.basenames == ['ConanFile']:
|
||||
for attr in node.body:
|
||||
children = list(attr.get_children())
|
||||
@@ -32,8 +41,12 @@ class PackageName(BaseChecker):
|
||||
isinstance(children[0], AssignName) and \
|
||||
children[0].name == "name" and \
|
||||
isinstance(children[1], Const):
|
||||
if is_test:
|
||||
self.add_message("conan-test-no-name", node=attr, line=attr.lineno)
|
||||
return
|
||||
value = children[1].as_string()
|
||||
if value.lower() != value:
|
||||
self.add_message("conan-bad-name", node=attr, line=attr.lineno)
|
||||
return
|
||||
self.add_message("conan-missing-name", node=node)
|
||||
if not is_test:
|
||||
self.add_message("conan-missing-name", node=node)
|
||||
|
Reference in New Issue
Block a user