From 54dbc3b43b13d398f9142e30664c998c7a2b08fc Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Feb 20 2020 06:15:52 +0000
Subject: [PATCH 1/5] Remove unnecessary variable initialization


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/freshmaker/utils.py b/freshmaker/utils.py
index 0d7dde4..df76d8e 100644
--- a/freshmaker/utils.py
+++ b/freshmaker/utils.py
@@ -316,7 +316,6 @@ def push_repo(repo, logger=None):
 
 def get_commit_hash(repo, branch='master', revision='HEAD', logger=None):
     """Get commit hash from revision"""
-    commit_hash = None
     cmd = ['git', 'rev-parse', revision]
     if '://' in repo:
         # this is a remote repo url
@@ -331,7 +330,6 @@ def get_commit_hash(repo, branch='master', revision='HEAD', logger=None):
 
 
 def bump_distgit_repo(namespace, name, branch='master', user=None, commit_author=None, commit_msg=None, logger=None):
-    rev = None
     with temp_dir(prefix='freshmaker-%s-%s-' % (namespace, name)) as repodir:
         try:
             msg = commit_msg or "Bump"

From 0e813ddb7f8ce6981eccd8db50a22c1532720209 Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Feb 20 2020 07:46:04 +0000
Subject: [PATCH 2/5] Fix some typos


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/freshmaker/events.py b/freshmaker/events.py
index 3c8aae5..31ebbc0 100644
--- a/freshmaker/events.py
+++ b/freshmaker/events.py
@@ -37,7 +37,7 @@ class BaseEvent(object):
         """
         A base class to abstract events from different fedmsg messages.
         :param msg_id: the id of the msg (e.g. 2016-SomeGUID)
-        :param manual: True if the event was trigerred manually by Freshmaker
+        :param manual: True if the event was triggered manually by Freshmaker
             REST API.
         :param dry_run: True if the event should be handled in DRY_RUN mode.
         """
@@ -205,7 +205,7 @@ class GitRPMSpecChangeEvent(BaseEvent):
 
 class TestingEvent(BaseEvent):
     """
-    Event useds in unit-tests.
+    Event used in unit-tests.
     """
     def __init__(self, msg_id, **kwargs):
         super(TestingEvent, self).__init__(msg_id, **kwargs)
diff --git a/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py b/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
index 864c3ec..de74968 100644
--- a/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
+++ b/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
@@ -369,7 +369,7 @@ class RebuildImagesOnRPMAdvisoryChange(ContainerBuildHandler):
         advisory.
 
         Found images are yielded in proper rebuild order from base images to
-        leaf images through the docker build dependnecy chain.
+        leaf images through the docker build dependency chain.
 
         :param int errata_id: Errata ID.
         """

From 72203dc9a3713a4ed068377e286dd4bd981ac9f2 Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Feb 20 2020 08:11:01 +0000
Subject: [PATCH 3/5] Simplify dict object creation


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/freshmaker/handlers/__init__.py b/freshmaker/handlers/__init__.py
index 7c6aebc..a7de567 100644
--- a/freshmaker/handlers/__init__.py
+++ b/freshmaker/handlers/__init__.py
@@ -558,12 +558,11 @@ class ContainerBuildHandler(BaseHandler):
         without contacting the ODCS server.
         """
         if self.dry_run:
-            compose = {}
-            compose['id'] = compose_id
-            compose['result_repofile'] = "http://localhost/%d.repo" % (
-                compose['id'])
-            compose['state'] = COMPOSE_STATES['done']
-            return compose
+            return {
+                'id': compose_id,
+                'result_repofile': "http://localhost/%d.repo" % compose_id,
+                'state': COMPOSE_STATES['done'],
+            }
 
         with krb_context():
             return create_odcs_client().get_compose(compose_id)
diff --git a/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py b/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
index de74968..d9dc7d0 100644
--- a/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
+++ b/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py
@@ -282,15 +282,15 @@ class RebuildImagesOnRPMAdvisoryChange(ContainerBuildHandler):
 
                 build.transition(state, state_reason)
 
-                build_args = {}
-                build_args["repository"] = image["repository"]
-                build_args["commit"] = image["commit"]
-                build_args["original_parent"] = parent_nvr
-                build_args["target"] = image["target"]
-                build_args["branch"] = image["git_branch"]
-                build_args["arches"] = image["arches"]
-                build_args["renewed_odcs_compose_ids"] = image["odcs_compose_ids"]
-                build.build_args = json.dumps(build_args)
+                build.build_args = json.dumps({
+                    "repository": image["repository"],
+                    "commit": image["commit"],
+                    "original_parent": parent_nvr,
+                    "target": image["target"],
+                    "branch": image["git_branch"],
+                    "arches": image["arches"],
+                    "renewed_odcs_compose_ids": image["odcs_compose_ids"],
+                })
 
                 db.session.commit()
 
diff --git a/freshmaker/logger.py b/freshmaker/logger.py
index e5ec380..570d7ab 100644
--- a/freshmaker/logger.py
+++ b/freshmaker/logger.py
@@ -43,11 +43,12 @@ logging.warning("%s failed to build", task_id)
 
 import logging
 
-levels = {}
-levels["debug"] = logging.DEBUG
-levels["error"] = logging.ERROR
-levels["warning"] = logging.WARNING
-levels["info"] = logging.INFO
+levels = {
+    "debug": logging.DEBUG,
+    "error": logging.ERROR,
+    "warning": logging.WARNING,
+    "info": logging.INFO,
+}
 
 
 def str_to_log_level(level):
diff --git a/freshmaker/odcsclient.py b/freshmaker/odcsclient.py
index 6796c80..5de3133 100644
--- a/freshmaker/odcsclient.py
+++ b/freshmaker/odcsclient.py
@@ -120,15 +120,12 @@ class FreshmakerODCSClient(object):
         if fake_compose_id >= 0:
             fake_compose_id = -1
 
-        new_compose = {}
-        new_compose['id'] = fake_compose_id
-        new_compose['result_repofile'] = "http://localhost/%d.repo" % (
-            new_compose['id'])
-        new_compose['state'] = COMPOSE_STATES['done']
-        if results is None:
-            new_compose['results'] = ['boot.iso']
-        else:
-            new_compose['results'] = results
+        new_compose = {
+            'id': fake_compose_id,
+            'result_repofile': "http://localhost/{}.repo".format(fake_compose_id),
+            'state': COMPOSE_STATES['done'],
+            'results': results or ['boot.iso']
+        }
         if builds:
             new_compose['builds'] = builds
 
diff --git a/freshmaker/views.py b/freshmaker/views.py
index 3f1c3da..7dafffc 100644
--- a/freshmaker/views.py
+++ b/freshmaker/views.py
@@ -171,10 +171,7 @@ class EventTypeAPI(MethodView):
             event_types.append({'name': cls.__name__, 'id': val})
 
         if id is None:
-            json_data = {}
-            json_data['items'] = event_types
-
-            return jsonify(json_data), 200
+            return jsonify({'items': event_types}), 200
 
         else:
             event_type = [x for x in event_types if x['id'] == id]
@@ -192,10 +189,7 @@ class BuildTypeAPI(MethodView):
             build_types.append({'name': x.name, 'id': x.value})
 
         if id is None:
-            json_data = {}
-            json_data['items'] = build_types
-
-            return jsonify(json_data), 200
+            return jsonify({'items': build_types}), 200
 
         else:
             build_type = [x for x in build_types if x['id'] == id]
@@ -213,10 +207,7 @@ class BuildStateAPI(MethodView):
             build_states.append({'name': x.name, 'id': x.value})
 
         if id is None:
-            json_data = {}
-            json_data['items'] = build_states
-
-            return jsonify(json_data), 200
+            return jsonify({'items': build_states}), 200
 
         else:
             build_state = [x for x in build_states if x['id'] == id]
@@ -675,10 +666,11 @@ class VerifyImageAPI(MethodView):
 
         verifier = ImageVerifier()
         images = verifier.verify_image(image)
-        ret = {}
-        ret["msg"] = ("Found %d images which are handled by Freshmaker for defined "
-                      "content_sets." % len(images))
-        ret["images"] = images
+        ret = {
+            "msg": "Found %d images which are handled by Freshmaker for "
+                   "defined content_sets." % len(images),
+            "images": images
+        }
         return jsonify(ret), 200
 
 
@@ -718,10 +710,11 @@ class VerifyImageRepositoryAPI(MethodView):
 
         verifier = ImageVerifier()
         images = verifier.verify_repository("%s/%s" % (project, repo))
-        ret = {}
-        ret["msg"] = ("Found %d images which are handled by Freshmaker for defined "
-                      "content_sets." % len(images))
-        ret["images"] = images
+        ret = {
+            "msg": "Found %d images which are handled by Freshmaker for "
+                   "defined content_sets." % len(images),
+            "images": images,
+        }
         return jsonify(ret), 200
 
 

From 00d401338d3f62ca3e144ba4424e6eab1fa649a8 Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Feb 20 2020 09:21:31 +0000
Subject: [PATCH 4/5] Fix type description in docstring


Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py
index c47a9c1..853cbf9 100644
--- a/freshmaker/lightblue.py
+++ b/freshmaker/lightblue.py
@@ -864,7 +864,7 @@ class LightBlue(object):
         :param list content_sets: List of content_sets the image includes RPMs
             from.
         :param list srpm_nvrs: list of SRPM NVRs to look for
-        :param list repositories: List of repository names to look for.
+        :param dict repositories: List of repository names to look for.
         :param bool published: whether to limit queries to published
             repositories
         :param bool include_rpms: whether to include the RPMs in the result.

From 222b4e78656d5ea6265748e52f4fd4e839939c10 Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Feb 20 2020 09:23:51 +0000
Subject: [PATCH 5/5] Fix inconsistent type of SFM2API.query_sfm2


* Fix return type description in query_sfm2 docstring.
* Remove unecessary "element" variable initialization which has wrong
  type.

Signed-off-by: Chenxiong Qi <cqi@redhat.com>

---

diff --git a/freshmaker/sfm2.py b/freshmaker/sfm2.py
index d9b6554..597b2a9 100644
--- a/freshmaker/sfm2.py
+++ b/freshmaker/sfm2.py
@@ -52,7 +52,7 @@ class SFM2API(object):
         It queries api/public/flaws?id=$cve&include_fields=affects,impact endpoint.
 
         :param str cve: CVE, for example "CVE-2017-10268".
-        :rtype: list
+        :rtype: dict
         :return: dict with two keys, "impact", and "affects". The first references
         the impact of the CVE, and the second is a list of dicts representing packages
         affected by the CVE.
@@ -79,7 +79,6 @@ class SFM2API(object):
         and "pkg_name" of the affected packages.
         """
         max_rating = -1
-        elements = []
         affected_pkgs = []
         severity = None
         for cve in cve_list:

