From 3e30d1a1d4d5be01629e0645e05bae19743b9d38 Mon Sep 17 00:00:00 2001
From: gnaponie <gnaponie@redhat.com>
Date: Jul 12 2019 08:02:19 +0000
Subject: [PATCH 1/2] Fix pylint


Signed-off-by: gnaponie <gnaponie@redhat.com>

---

diff --git a/greenwave/policies.py b/greenwave/policies.py
index e1ee597..b91237e 100644
--- a/greenwave/policies.py
+++ b/greenwave/policies.py
@@ -493,7 +493,6 @@ class PassingTestCaseRule(Rule):
                     visited_arch_variants.add(arch_variant)
                     answer = self._answer_for_result(
                         result,
-                        product_version,
                         policy.subject_type,
                         subject_identifier)
                     answers.append(answer)
@@ -507,7 +506,6 @@ class PassingTestCaseRule(Rule):
         for result in matching_results:
             answers.append(self._answer_for_result(
                 result,
-                product_version,
                 policy.subject_type,
                 subject_identifier))
         return answers
@@ -524,7 +522,7 @@ class PassingTestCaseRule(Rule):
         }
 
     def _answer_for_result(
-            self, result, product_version, subject_type, subject_identifier):
+            self, result, subject_type, subject_identifier):
         if result['outcome'] in ('PASSED', 'INFO'):
             log.debug('Test result passed for the result_id %s and testcase %s,'
                       ' because the outcome is %s', result['id'], self.test_case_name,
diff --git a/greenwave/request_session.py b/greenwave/request_session.py
index aad59e1..1003581 100644
--- a/greenwave/request_session.py
+++ b/greenwave/request_session.py
@@ -1,6 +1,7 @@
 import requests
 
 from requests.adapters import HTTPAdapter
+# pylint: disable=E0401
 from requests.packages.urllib3.util.retry import Retry
 
 from greenwave import __version__
diff --git a/greenwave/resources.py b/greenwave/resources.py
index 47f349b..0aaa3ac 100644
--- a/greenwave/resources.py
+++ b/greenwave/resources.py
@@ -196,7 +196,7 @@ def _retrieve_yaml_remote_rule_git_archive(rev, pkg_name, pkg_namespace):
     cmd = ['git', 'archive', f'--remote={dist_git_url}', rev, 'gating.yaml']
     # Retry thrice if TimeoutExpired exception is raised
     MAX_RETRY = 3
-    for tries in range(MAX_RETRY):
+    for _ in range(MAX_RETRY):
         try:
             git_archive = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
             output, error_output = git_archive.communicate(timeout=30)
diff --git a/greenwave/tests/test_api_v1.py b/greenwave/tests/test_api_v1.py
index e29d7d0..59ef253 100644
--- a/greenwave/tests/test_api_v1.py
+++ b/greenwave/tests/test_api_v1.py
@@ -63,6 +63,8 @@ def make_decision(**kwargs):
 
 
 def test_make_decision_retrieves_waivers_on_missing(mock_results, mock_waivers):
+    mock_results.return_value = []
+    mock_waivers.return_value = []
     response = make_decision()
     assert 200 == response.status_code
     assert '1 of 1 required test results missing' == response.json['summary']
@@ -71,6 +73,7 @@ def test_make_decision_retrieves_waivers_on_missing(mock_results, mock_waivers):
 
 def test_make_decision_retrieves_waivers_on_failed(mock_results, mock_waivers):
     mock_results.return_value = [make_result(outcome='FAILED')]
+    mock_waivers.return_value = []
     response = make_decision()
     assert 200 == response.status_code
     assert '1 of 1 required tests failed' == response.json['summary']
@@ -79,6 +82,7 @@ def test_make_decision_retrieves_waivers_on_failed(mock_results, mock_waivers):
 
 def test_make_decision_retrieves_waivers_omitted_on_passed(mock_results, mock_waivers):
     mock_results.return_value = [make_result(outcome='PASSED')]
+    mock_waivers.return_value = []
     response = make_decision()
     assert 200 == response.status_code
     assert 'All required tests passed' == response.json['summary']
@@ -86,6 +90,8 @@ def test_make_decision_retrieves_waivers_omitted_on_passed(mock_results, mock_wa
 
 
 def test_make_decision_retrieves_waivers_once_on_verbose_and_missing(mock_results, mock_waivers):
+    mock_results.return_value = []
+    mock_waivers.return_value = []
     response = make_decision(verbose=True)
     assert 200 == response.status_code
     assert '1 of 1 required test results missing' == response.json['summary']
diff --git a/greenwave/tests/test_resultsdb_consumer.py b/greenwave/tests/test_resultsdb_consumer.py
index e66c235..227029e 100644
--- a/greenwave/tests/test_resultsdb_consumer.py
+++ b/greenwave/tests/test_resultsdb_consumer.py
@@ -331,6 +331,7 @@ def test_guess_product_version():
 
 
 def test_guess_product_version_with_koji():
+    # pylint: disable=W0212,W0612
     class DummyKojiProxy():
         def getBuild(self, subject_identifier):
             assert 'fake_koji_build' == subject_identifier
@@ -353,6 +354,7 @@ def test_guess_product_version_with_koji():
     'badnvr-1.2.f30',
 ))
 def test_guess_product_version_failure(nvr):
+    # pylint: disable=W0212
     product_version = greenwave.consumers.resultsdb._subject_product_version(nvr, 'koji_build')
     assert product_version is None
 
diff --git a/greenwave/tests/test_waivers_retriever.py b/greenwave/tests/test_waivers_retriever.py
index 4b201cb..6cfa3d9 100644
--- a/greenwave/tests/test_waivers_retriever.py
+++ b/greenwave/tests/test_waivers_retriever.py
@@ -16,6 +16,7 @@ _DUMMY_FILTERS = ['dummy_filter']
 
 
 def test_waivers_retriever_retrieves_not_ignored_ids():
+    # pylint: disable=W0212
     retriever = WaiversRetriever(**_DUMMY_RETRIEVER_ARGUMENTS)
     retriever.ignore_ids = [100]
     waiver = dict(
@@ -32,6 +33,7 @@ def test_waivers_retriever_retrieves_not_ignored_ids():
 
 
 def test_waivers_retriever_ignores_ids():
+    # pylint: disable=W0212
     retriever = WaiversRetriever(**_DUMMY_RETRIEVER_ARGUMENTS)
     retriever.ignore_ids = [99]
     waiver = dict(
@@ -48,6 +50,7 @@ def test_waivers_retriever_ignores_ids():
 
 
 def test_waivers_retriever_ignores_no_waived():
+    # pylint: disable=W0212
     retriever = WaiversRetriever(**_DUMMY_RETRIEVER_ARGUMENTS)
     waiver = dict(
         id=99,
diff --git a/pylintrc b/pylintrc
index bfe20a0..5e4da35 100644
--- a/pylintrc
+++ b/pylintrc
@@ -1,2 +1,2 @@
 [MESSAGES CONTROL]
-disable=R,C,no-member,fixme,W0622
+disable=R,C,no-member,fixme,W0622,W0621

From a79e535f5781ec039b32d3238b8e44115d1a374b Mon Sep 17 00:00:00 2001
From: gnaponie <gnaponie@redhat.com>
Date: Jul 12 2019 08:27:20 +0000
Subject: [PATCH 2/2] Replace pylint codes with verbal short identifiers


Signed-off-by: gnaponie <gnaponie@redhat.com>

---

diff --git a/greenwave/policies.py b/greenwave/policies.py
index b91237e..5baba0c 100644
--- a/greenwave/policies.py
+++ b/greenwave/policies.py
@@ -331,6 +331,7 @@ class Rule(SafeYAMLObject):
 
     @staticmethod
     def process_on_demand_rules(rules):
+        #pylint: disable=attribute-defined-outside-init
         """
         Validates rules and creates objects for them.
 
@@ -351,8 +352,8 @@ class Rule(SafeYAMLObject):
                 processed_rules.append(RemoteRule())
             elif rule['type'] == 'PassingTestCaseRule':
                 temp_rule = PassingTestCaseRule()
-                temp_rule.test_case_name = rule['test_case_name']  # pylint: disable=W0201
-                temp_rule.scenario = rule.get('scenario')  # pylint: disable=W0201
+                temp_rule.test_case_name = rule['test_case_name']
+                temp_rule.scenario = rule.get('scenario')
                 processed_rules.append(temp_rule)
             else:
                 raise BadRequest('Invalid rule type {}'.format(rule['type']))
@@ -679,7 +680,7 @@ class OnDemandPolicy(Policy):
         policy.relevance_key = data_dict.get('relevance_key')
 
         # Validate the data before processing.
-        policy.__validate_attributes()  # pylint: disable=W0212
+        policy.__validate_attributes()  # pylint: disable=protected-access
         return policy
 
     def __validate_attributes(self):
diff --git a/greenwave/request_session.py b/greenwave/request_session.py
index 1003581..d878872 100644
--- a/greenwave/request_session.py
+++ b/greenwave/request_session.py
@@ -1,7 +1,7 @@
 import requests
 
 from requests.adapters import HTTPAdapter
-# pylint: disable=E0401
+# pylint: disable=import-error
 from requests.packages.urllib3.util.retry import Retry
 
 from greenwave import __version__
diff --git a/greenwave/tests/test_policies.py b/greenwave/tests/test_policies.py
index c8256a1..bd0c628 100644
--- a/greenwave/tests/test_policies.py
+++ b/greenwave/tests/test_policies.py
@@ -912,7 +912,7 @@ def test_remote_rule_policy_on_demand_policy(namespace):
             scm.return_value = (namespace, 'nethack', 'c3c47a08a66451cb9686c49f040776ed35a0d1bb')
             with mock.patch('greenwave.resources.retrieve_yaml_remote_rule') as f:
                 f.return_value = remote_fragment
-                policy = OnDemandPolicy.create_from_json(serverside_json)  # pylint: disable=W0212
+                policy = OnDemandPolicy.create_from_json(serverside_json)
 
                 # Ensure that presence of a result is success.
                 results = DummyResultsRetriever(nvr, 'dist.upgradepath')
diff --git a/greenwave/tests/test_resultsdb_consumer.py b/greenwave/tests/test_resultsdb_consumer.py
index 227029e..ec3e083 100644
--- a/greenwave/tests/test_resultsdb_consumer.py
+++ b/greenwave/tests/test_resultsdb_consumer.py
@@ -313,7 +313,7 @@ def test_remote_rule_decision_change_not_matching(
 
 
 def test_guess_product_version():
-    # pylint: disable=W0212
+    # pylint: disable=protected-access
     hub = mock.MagicMock()
     hub.config = {
         'environment': 'environment',
@@ -331,7 +331,7 @@ def test_guess_product_version():
 
 
 def test_guess_product_version_with_koji():
-    # pylint: disable=W0212,W0612
+    # pylint: disable=protected-access,unused-variable
     class DummyKojiProxy():
         def getBuild(self, subject_identifier):
             assert 'fake_koji_build' == subject_identifier
@@ -354,7 +354,7 @@ def test_guess_product_version_with_koji():
     'badnvr-1.2.f30',
 ))
 def test_guess_product_version_failure(nvr):
-    # pylint: disable=W0212
+    # pylint: disable=protected-access
     product_version = greenwave.consumers.resultsdb._subject_product_version(nvr, 'koji_build')
     assert product_version is None
 
diff --git a/greenwave/tests/test_waivers_retriever.py b/greenwave/tests/test_waivers_retriever.py
index 6cfa3d9..ff6b8e6 100644
--- a/greenwave/tests/test_waivers_retriever.py
+++ b/greenwave/tests/test_waivers_retriever.py
@@ -16,7 +16,7 @@ _DUMMY_FILTERS = ['dummy_filter']
 
 
 def test_waivers_retriever_retrieves_not_ignored_ids():
-    # pylint: disable=W0212
+    # pylint: disable=protected-access
     retriever = WaiversRetriever(**_DUMMY_RETRIEVER_ARGUMENTS)
     retriever.ignore_ids = [100]
     waiver = dict(
@@ -33,7 +33,7 @@ def test_waivers_retriever_retrieves_not_ignored_ids():
 
 
 def test_waivers_retriever_ignores_ids():
-    # pylint: disable=W0212
+    # pylint: disable=protected-access
     retriever = WaiversRetriever(**_DUMMY_RETRIEVER_ARGUMENTS)
     retriever.ignore_ids = [99]
     waiver = dict(
@@ -50,7 +50,7 @@ def test_waivers_retriever_ignores_ids():
 
 
 def test_waivers_retriever_ignores_no_waived():
-    # pylint: disable=W0212
+    # pylint: disable=protected-access
     retriever = WaiversRetriever(**_DUMMY_RETRIEVER_ARGUMENTS)
     waiver = dict(
         id=99,
diff --git a/pylintrc b/pylintrc
index 5e4da35..d822d3e 100644
--- a/pylintrc
+++ b/pylintrc
@@ -1,2 +1,2 @@
 [MESSAGES CONTROL]
-disable=R,C,no-member,fixme,W0622,W0621
+disable=R,C,no-member,fixme,redefined-builtin,redefined-outer-name

