[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Pki-devel] [PATCH] 69 Last set of fixes for warnings and errors reported by pylint for Dogtag10.1 branch



Please review the patch with fixes for remaining two issues reported by
pylint.

1. Attribute defined outside init.
2. Instance attribute hiding a class method (Ignored as the problem is
in json.encoder.JSONEncoder).

Also attached the final report.

--Abhishek
>From 253384596d3bf6c5d51f4bc7f6d9e98a7e12f12c Mon Sep 17 00:00:00 2001
From: Abhishek Koneru <akoneru redhat com>
Date: Wed, 17 Jul 2013 14:21:30 -0400
Subject: [PATCH] Fixes for issues reported by pylint.

Fixed the warning W0202 - attributes defined outside init and
error E0202 - An instance attribute hiding a method (which is actually
an error in json.encoder.JSONEncoder line 157.)
---
 base/common/python/pki/encoder.py     |    4 ++--
 base/common/python/pki/system.py      |    2 +-
 base/server/src/engine/pkihelper.py   |    8 ++++----
 base/server/src/engine/pkimanifest.py |    9 ++++++++-
 base/server/src/engine/pkiparser.py   |    2 ++
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/base/common/python/pki/encoder.py b/base/common/python/pki/encoder.py
index 8d8a9c10198cc189b10e1a1ae993c36ab9de25dd..0963751c29d94c76dcaa44bc30f1bd2b2174e4c0 100644
--- a/base/common/python/pki/encoder.py
+++ b/base/common/python/pki/encoder.py
@@ -10,8 +10,8 @@ class CustomTypeEncoder(json.JSONEncoder):
     Custom objects are encoded as JSON object literals (ie, dicts) with
     one key, 'TypeName' where 'TypeName' is the actual name of the
     type to which the object belongs.  That single key maps to another
-    object literal which is just the __dict__ of the object encoded."""
-
+    object literal which is just the __dict__ of the object encoded.E0202"""
+    # pylint: disable-msg=E0202
     def default(self, obj):
         for k, v in TYPES.items():
             if isinstance(obj, v):
diff --git a/base/common/python/pki/system.py b/base/common/python/pki/system.py
index 4dd3baac2ddcafc4763a485ce0e5418c193a6bbd..9ea93677afee865875e72de6aaf95ad21ed8ef0d 100644
--- a/base/common/python/pki/system.py
+++ b/base/common/python/pki/system.py
@@ -25,7 +25,7 @@ import xml.etree.ElementTree as ET
 class SecurityDomainInfo:
 
     def __init__(self):
-        pass
+        self.name = None
 
 class SecurityDomainClient:
 
diff --git a/base/server/src/engine/pkihelper.py b/base/server/src/engine/pkihelper.py
index 39a0b8b9efa2c2765fcc706018dc58ab4abcb66e..6d47a902bb589c5ccccf0433233f042e0d7dd02e 100644
--- a/base/server/src/engine/pkihelper.py
+++ b/base/server/src/engine/pkihelper.py
@@ -1041,7 +1041,7 @@ class Instance:
             raise
 
     def get_instance_status(self):
-        self.connection = pki.client.PKIConnection(
+        connection = pki.client.PKIConnection(
             protocol='https',
             hostname=self.master_dict['pki_hostname'],
             port=self.master_dict['pki_https_port'],
@@ -1049,7 +1049,7 @@ class Instance:
             accept='application/xml')
 
         try:
-            client = pki.system.SystemStatusClient(self.connection)
+            client = pki.system.SystemStatusClient(connection)
             response = client.getStatus()
             config.pki_log.debug(response,
                 extra=config.PKI_INDENTATION_LEVEL_3)
@@ -3070,14 +3070,14 @@ class ConfigClient:
         config.pki_log.info(log.PKI_CONFIG_CONFIGURING_PKI_DATA,
                              extra=config.PKI_INDENTATION_LEVEL_2)
 
-        self.connection = pki.client.PKIConnection(
+        connection = pki.client.PKIConnection(
             protocol='https',
             hostname=self.master_dict['pki_hostname'],
             port=self.master_dict['pki_https_port'],
             subsystem=self.master_dict['pki_subsystem_type'])
 
         try:
-            client = pki.system.SystemConfigClient(self.connection)
+            client = pki.system.SystemConfigClient(connection)
             response = client.configure(data)
 
             config.pki_log.debug(log.PKI_CONFIG_RESPONSE_STATUS + \
diff --git a/base/server/src/engine/pkimanifest.py b/base/server/src/engine/pkimanifest.py
index 09079b4334c713959a5d76735b43515983c40159..dea2af275656f5f319ffedae7012e6f545d48003 100644
--- a/base/server/src/engine/pkimanifest.py
+++ b/base/server/src/engine/pkimanifest.py
@@ -45,7 +45,14 @@ class Record(object):
                "acls",
 
     def __init__(self):
-        pass
+        self.name = None
+        self.type = None
+        self.user = None
+        self.group = None
+        self.uid = None
+        self.gid = None
+        self.permissions = None
+        self.acls = None
 
     def items(self):
         "dict style items"
diff --git a/base/server/src/engine/pkiparser.py b/base/server/src/engine/pkiparser.py
index dfd48b00ddca99927cb0f588ee87eadabe46660c..8dbed8deb97dfcf36a5cf924b06796f827d5e96b 100644
--- a/base/server/src/engine/pkiparser.py
+++ b/base/server/src/engine/pkiparser.py
@@ -83,6 +83,8 @@ class PKIConfigParser:
                           help='directory prefix to specify local directory '
                                '[TEST ONLY]')
         self.indent = 0
+        self.ds_connection = None
+        self.sd_connection = None
 
         # Master and Slot dictionaries
         self.pki_master_dict = dict()
-- 
1.7.10.2


Report
======
8030 statements analysed.

External dependencies
---------------------
::

    ldap (pki.deployment.pkiparser,pkispawn)
    pki (pki-upgrade,pki.upgrade,pki.deployment.pkiparser,pki.server,pki/server/,pki-server-upgrade,pki.server.upgrade)
      \-account (pki.deployment.pkiparser,pki.deployment.pkihelper)
      \-client (pki.deployment.pkiparser,pki.deployment.pkihelper)
      \-deployment 
      | \-pkiconfig (pki.deployment.pkihelper,pki.deployment.webapp_deployment,pki.deployment.pkimanifest,pki.deployment.pkiparser,pkidestroy,pki.deployment.initialization,pki.deployment.selinux_setup,pki.deployment.instance_layout,pki.deployment.security_databases,pkispawn,pki.deployment.infrastructure_layout,pki.deployment.finalization,pki.deployment.configuration,pki.deployment.slot_substitution,pki.deployment.subsystem_layout)
      | | \-pki_selinux_config_ports (pki.deployment.pkihelper,pki.deployment.selinux_setup)
      | \-pkihelper (pkidestroy,pkispawn)
      | \-pkilogging (pki.deployment.pkiparser,pkidestroy,pkispawn)
      | \-pkimanifest (pki.deployment.pkihelper,pki.deployment.finalization)
      | \-pkimessages (pki.deployment.pkihelper,pki.deployment.webapp_deployment,pki.deployment.pkimanifest,pki.deployment.pkiparser,pkidestroy,pki.deployment.initialization,pki.deployment.selinux_setup,pki.deployment.instance_layout,pki.deployment.security_databases,pkispawn,pki.deployment.infrastructure_layout,pki.deployment.finalization,pki.deployment.configuration,pki.deployment.slot_substitution,pki.deployment.subsystem_layout)
      | \-pkiparser 
      | | \-PKIConfigParser (pki.deployment.pkihelper,pkidestroy,pkispawn)
      | \-pkiscriptlet (pki.deployment.webapp_deployment,pki.deployment.finalization,pki.deployment.initialization,pki.deployment.selinux_setup,pki.deployment.instance_layout,pki.deployment.security_databases,pki.deployment.infrastructure_layout,pki.deployment.configuration,pki.deployment.slot_substitution,pki.deployment.subsystem_layout)
      \-encoder (pki.system,pki.deployment.configuration)
      \-server (pki.server.upgrade)
      | \-upgrade (pki-server-upgrade)
      \-system (pki.deployment.pkiparser,pki.deployment.pkihelper,pki.deployment.configuration)
      \-upgrade (pki.deployment.pkiparser,pki-server-upgrade,pki.server.upgrade,pki-upgrade)
      | \-verbose (pki.server.upgrade)
      \-util (pki.upgrade)
    requests (pki.deployment.pkiparser,pki.client,pkispawn,pki.deployment.pkihelper)
    selinux (pki.deployment.pkihelper,pki.deployment.selinux_setup)
    seobject (pki.deployment.pkihelper,pki.deployment.selinux_setup)



Statistics by type
------------------

+---------+-------+-----------+-----------+------------+---------+
|type     |number |old number |difference |%documented |%badname |
+=========+=======+===========+===========+============+=========+
|module   |51     |51         |=          |NC          |NC       |
+---------+-------+-----------+-----------+------------+---------+
|class    |86     |86         |=          |NC          |NC       |
+---------+-------+-----------+-----------+------------+---------+
|method   |407    |407        |=          |NC          |NC       |
+---------+-------+-----------+-----------+------------+---------+
|function |32     |32         |=          |NC          |NC       |
+---------+-------+-----------+-----------+------------+---------+



Messages by category
--------------------

+-----------+-------+---------+-----------+
|type       |number |previous |difference |
+===========+=======+=========+===========+
|convention |0      |0        |=          |
+-----------+-------+---------+-----------+
|refactor   |0      |0        |=          |
+-----------+-------+---------+-----------+
|warning    |0      |0        |=          |
+-----------+-------+---------+-----------+
|error      |0      |1        |-1.00      |
+-----------+-------+---------+-----------+



Global evaluation
-----------------
Your code has been rated at 10.00/10 (previous run: 9.99/10)

Duplication
-----------

+-------------------------+-------+---------+-----------+
|                         |now    |previous |difference |
+=========================+=======+=========+===========+
|nb duplicated lines      |7564   |7564     |=          |
+-------------------------+-------+---------+-----------+
|percent duplicated lines |45.687 |45.687   |=          |
+-------------------------+-------+---------+-----------+



Raw metrics
-----------

+----------+-------+------+---------+-----------+
|type      |number |%     |previous |difference |
+==========+=======+======+=========+===========+
|code      |11088  |73.76 |11088    |=          |
+----------+-------+------+---------+-----------+
|docstring |990    |6.59  |990      |=          |
+----------+-------+------+---------+-----------+
|comment   |1920   |12.77 |1919     |+1.00      |
+----------+-------+------+---------+-----------+
|empty     |1034   |6.88  |1035     |-1.00      |
+----------+-------+------+---------+-----------+




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]