Module: check_mk
Branch: master
Commit: 261ed98297ef7c8ff8589ff7507ef15335d3252a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=261ed98297ef7c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jul 24 12:59:58 2018 +0200
Removed pylint checker superceded by pylint_checker_localization
Change-Id: Ia4e8ade42501a78cac8b56fd9df4647f72dad2cd
---
tests/pylint/pylintrc | 1 -
tests/testlib/pylint_checker_wrong_i18n.py | 79 ------------------------------
2 files changed, 80 deletions(-)
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index deb03dc..ab09382 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -5,7 +5,6 @@ init-hook=
test_path = os.environ.get("TEST_PATH", os.environ["HOME"] +
"/git/check_mk/tests")
sys.path.insert(0, test_path)
import conftest
-# load-plugins=testlib.pylint_cmk,testlib.pylint_checker_wrong_i18n
load-plugins=testlib.pylint_cmk,testlib.pylint_checker_localization
# TODO: Why do we need persistence?
persistent=yes
diff --git a/tests/testlib/pylint_checker_wrong_i18n.py
b/tests/testlib/pylint_checker_wrong_i18n.py
deleted file mode 100644
index 602b520..0000000
--- a/tests/testlib/pylint_checker_wrong_i18n.py
+++ /dev/null
@@ -1,79 +0,0 @@
-"""Checker for incorrect string translation functions."""
-
-import six
-
-import astroid
-
-from pylint.checkers import BaseChecker, utils
-from pylint.interfaces import IAstroidChecker
-
-BASE_ID = 76
-
-def register(linter):
- """Register checkers."""
- linter.register_checker(TranslationStringConstantsChecker(linter))
-
-
-class TranslationStringConstantsChecker(BaseChecker):
- """
- Checks for i18n translation functions (_, ugettext, ungettext, and many
- others) being called on something that isn't a string literal.
-
- Bad:
- _("hello {}".format(name))
- ugettext("Hello " + name)
- ugettext(value_from_database)
-
- OK:
- _("hello {}").format(name)
-
- The message id is `translation-of-non-string`.
-
- """
-
- __implements__ = (IAstroidChecker,)
-
- name = 'translation-string-checker'
-
- TRANSLATION_FUNCTIONS = set([
- '_',
- 'gettext',
- 'ngettext', 'ngettext_lazy',
- 'npgettext', 'npgettext_lazy',
- 'pgettext', 'pgettext_lazy',
- 'ugettext', 'ugettext_lazy', 'ugettext_noop',
- 'ungettext', 'ungettext_lazy',
- ])
-
- MESSAGE_ID = 'translation-of-non-string'
- msgs = {
- 'E%d10' % BASE_ID: (
- "i18n function %s() must be called with a literal string",
- MESSAGE_ID,
- "i18n functions must be called with a literal string",
- ),
- }
-
- @utils.check_messages(MESSAGE_ID)
- def visit_callfunc(self, node):
- """Called for every function call in the source
code."""
-
- if not isinstance(node.func, astroid.Name):
- # It isn't a simple name, can't deduce what function it is.
- return
-
- if node.func.name not in self.TRANSLATION_FUNCTIONS:
- # Not a function we care about.
- return
-
- if not self.linter.is_message_enabled(self.MESSAGE_ID, line=node.fromlineno):
- return
-
- first = node.args[0]
- if isinstance(first, astroid.Const):
- if isinstance(first.value, six.string_types):
- # The first argument is a constant string! All is well!
- return
-
- # Bad!
- self.add_message(self.MESSAGE_ID, args=node.func.name, node=node)