Skip to content

Commit 90a67a9

Browse files
committed
Code quality
1 parent 9bdae27 commit 90a67a9

12 files changed

Lines changed: 50 additions & 53 deletions

setup.cfg

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ ignore = bitmessagekivy
2424
[pylint.messages_control]
2525
disable =
2626
invalid-name,bare-except,broad-except,relative-import,
27-
superfluous-parens,bad-option-value,fixme
27+
superfluous-parens,bad-option-value,fixme,missing-docstring,
28+
too-many-locals,too-few-public-methods,too-many-statements,
29+
too-many-instance-attributes,too-many-public-methods
2830
# invalid-name: needs fixing during a large, project-wide refactor
2931
# bare-except,broad-except: Need fixing once thorough testing is easier
3032
# bad-option-value is for backward compatibility between python 2 and 3
@@ -42,7 +44,9 @@ ignore = bitmessagekivy
4244
[MESSAGES CONTROL]
4345
disable =
4446
invalid-name,bare-except,broad-except,relative-import,
45-
superfluous-parens,bad-option-value,fixme
47+
superfluous-parens,bad-option-value,fixme,missing-docstring,
48+
too-many-locals,too-few-public-methods,too-many-statements,
49+
too-many-instance-attributes,too-many-public-methods
4650

4751
[DESIGN]
4852
max-args = 8

src/bitmessagecli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ def apiInit(apiEnabled):
188188
def apiData():
189189
"""TBC"""
190190

191-
global keysName
192191
global keysPath
193192
global usrPrompt
194193

src/bitmessageqt/__init__.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
PyQt based UI for bitmessage, the main module
33
"""
44
# pylint: disable=import-error,too-many-lines,no-member
5+
# pylint: disable=too-many-branches
56
import hashlib
67
import locale
78
import os
@@ -760,6 +761,11 @@ def __init__(self, parent=None):
760761

761762
self.unreadCount = 0
762763

764+
self.currentTrayIconFileName = ""
765+
self.actionQuiet = None
766+
self.actionShow = None
767+
self.tray = None
768+
763769
# Set the icon sizes for the identicons
764770
identicon_size = 3 * 7
765771
self.ui.tableWidgetInbox.setIconSize(QtCore.QSize(identicon_size, identicon_size))
@@ -3978,12 +3984,12 @@ def on_context_menuInbox(self, point):
39783984
popMenuInbox.addAction(self.actionReply)
39793985
popMenuInbox.addAction(self.actionAddSenderToAddressBook)
39803986
# pylint: disable=no-member
3981-
self.actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction(
3987+
actionClipboardMessagelist = self.ui.inboxContextMenuToolbar.addAction(
39823988
_translate("MainWindow", "Copy subject to clipboard")
39833989
if tableWidget.currentColumn() == 2 else
39843990
_translate("MainWindow", "Copy address to clipboard"),
39853991
self.on_action_ClipboardMessagelist)
3986-
popMenuInbox.addAction(self.actionClipboardMessagelist)
3992+
popMenuInbox.addAction(actionClipboardMessagelist)
39873993
# pylint: disable=no-member
39883994
self._contact_selected = tableWidget.item(currentRow, 1)
39893995
# preloaded gui.menu plugins with prefix 'address'
@@ -4229,7 +4235,7 @@ class BitmessageQtApplication(QtGui.QApplication):
42294235
"""
42304236

42314237
# Unique identifier for this application
4232-
uuid = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'
4238+
UUID = '6ec0149b-96e1-4be1-93ab-1465fb3ebf7c'
42334239

42344240
@staticmethod
42354241
def get_windowstyle():
@@ -4241,7 +4247,6 @@ def get_windowstyle():
42414247

42424248
def __init__(self, *argv):
42434249
super(BitmessageQtApplication, self).__init__(*argv)
4244-
id = BitmessageQtApplication.uuid
42454250

42464251
QtCore.QCoreApplication.setOrganizationName("PyBitmessage")
42474252
QtCore.QCoreApplication.setOrganizationDomain("bitmessage.org")
@@ -4259,14 +4264,14 @@ def __init__(self, *argv):
42594264
self.is_running = False
42604265

42614266
socket = QLocalSocket()
4262-
socket.connectToServer(id)
4267+
socket.connectToServer(self.UUID)
42634268
self.is_running = socket.waitForConnected()
42644269

42654270
# Cleanup past crashed servers
42664271
if not self.is_running:
42674272
if socket.error() == QLocalSocket.ConnectionRefusedError:
42684273
socket.disconnectFromServer()
4269-
QLocalServer.removeServer(id)
4274+
QLocalServer.removeServer(self.UUID)
42704275

42714276
socket.abort()
42724277

@@ -4278,7 +4283,7 @@ def __init__(self, *argv):
42784283
# Nope, create a local server with this id and assign on_new_connection
42794284
# for whenever a second instance tries to run focus the application.
42804285
self.server = QLocalServer()
4281-
self.server.listen(id)
4286+
self.server.listen(self.UUID)
42824287
self.server.newConnection.connect(self.on_new_connection)
42834288

42844289
self.setStyleSheet("QStatusBar::item { border: 0px solid black }")
@@ -4293,20 +4298,20 @@ def on_new_connection(self):
42934298

42944299

42954300
def init():
4296-
global app
4301+
global app # pylint: disable=global-statement
42974302
if not app:
42984303
app = BitmessageQtApplication(sys.argv)
42994304
return app
43004305

43014306

43024307
def run():
4303-
global myapp
4304-
app = init()
4305-
myapp = MyForm()
4308+
global myapp # pylint: disable=global-statement
4309+
_app = init()
4310+
myapp = MyForm() # pylint: disable=redefined-outer-name
43064311

43074312
myapp.appIndicatorInit(app)
43084313

4309-
if myapp._firstrun:
4314+
if myapp._firstrun: # pylint: disable=protected-access
43104315
myapp.showConnectDialog() # ask the user if we may connect
43114316

43124317
# only show after wizards and connect dialogs have completed
@@ -4315,4 +4320,4 @@ def run():
43154320
QtCore.QTimer.singleShot(
43164321
30000, lambda: myapp.setStatusIcon(state.statusIconColor))
43174322

4318-
app.exec_()
4323+
_app.exec_()

src/bitmessageqt/account.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def accountClass(address):
6868
if subscription.type != AccountMixin.BROADCAST:
6969
return None
7070
else:
71+
# pylint: disable=redefined-variable-type
7172
subscription = SubscriptionAccount(address)
7273
if subscription.type != AccountMixin.SUBSCRIPTION:
7374
# e.g. deleted chan

src/bitmessageqt/bitmessage_icons_rc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
# WARNING! All changes made in this file will be lost!
99

10+
# pylint: disable=too-many-lines
1011
from PyQt4 import QtCore # pylint: disable=import-error
1112

1213
qt_resource_data = "\

src/bitmessageqt/foldertree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ def setLabel(self, label=None):
410410
AccountMixin.NORMAL,
411411
AccountMixin.CHAN, AccountMixin.MAILINGLIST):
412412
try:
413+
# pylint: disable=redefined-variable-type
413414
newLabel = unicode(
414415
config.get(self.address, 'label'),
415416
'utf-8', 'ignore')

src/bitmessageqt/migrationwizard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self):
6666

6767

6868
class Ui_MigrationWizard(QtGui.QWizard):
69+
# pylint: disable=redefined-variable-type
6970
def __init__(self, addresses):
7071
super(QtGui.QWizard, self).__init__()
7172

src/bitmessageqt/uisignaler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get(cls):
1717
cls._instance = UISignaler()
1818
return cls._instance
1919

20+
# pylint: disable=too-many-branches
2021
def run(self):
2122
while True:
2223
command, data = queues.UISignalQueue.get()

src/class_singleWorker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ def requestPubKey(self, toAddress):
13991399
TTL = 2.5 * 24 * 60 * 60
14001400
TTL *= 2 ** retryNumber
14011401
if TTL > 28 * 24 * 60 * 60:
1402-
TTL = 28 * 24 * 60 * 60
1402+
TTL = float(28 * 24 * 60 * 60)
14031403
# add some randomness to the TTL
14041404
TTL = TTL + helper_random.randomrandrange(-300, 300)
14051405
embeddedTime = int(time.time() + TTL)

src/class_sqlThread.py

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ def run(self):
108108
# usedpersonally field in their pubkeys table. Let's add it.
109109
if settingsversion == 2:
110110
item = '''ALTER TABLE pubkeys ADD usedpersonally text DEFAULT 'no' '''
111-
parameters = ''
112-
self.cur.execute(item, parameters)
111+
self.cur.execute(item)
113112
self.conn.commit()
114113

115114
settingsversion = 3
@@ -119,16 +118,13 @@ def run(self):
119118
# in the inbox table. Let's add them.
120119
if settingsversion == 3:
121120
item = '''ALTER TABLE inbox ADD encodingtype int DEFAULT '2' '''
122-
parameters = ''
123-
self.cur.execute(item, parameters)
121+
self.cur.execute(item)
124122

125123
item = '''ALTER TABLE inbox ADD read bool DEFAULT '1' '''
126-
parameters = ''
127-
self.cur.execute(item, parameters)
124+
self.cur.execute(item)
128125

129126
item = '''ALTER TABLE sent ADD encodingtype int DEFAULT '2' '''
130-
parameters = ''
131-
self.cur.execute(item, parameters)
127+
self.cur.execute(item)
132128
self.conn.commit()
133129

134130
settingsversion = 4
@@ -144,8 +140,7 @@ def run(self):
144140
# version we are on can stay embedded in the messages.dat file. Let us
145141
# check to see if the settings table exists yet.
146142
item = '''SELECT name FROM sqlite_master WHERE type='table' AND name='settings';'''
147-
parameters = ''
148-
self.cur.execute(item, parameters)
143+
self.cur.execute(item)
149144
if self.cur.fetchall() == []:
150145
# The settings table doesn't exist. We need to make it.
151146
logger.debug(
@@ -199,8 +194,7 @@ def run(self):
199194
# Let's get rid of the first20bytesofencryptedmessage field in
200195
# the inventory table.
201196
item = '''SELECT value FROM settings WHERE key='version';'''
202-
parameters = ''
203-
self.cur.execute(item, parameters)
197+
self.cur.execute(item)
204198
if int(self.cur.fetchall()[0][0]) == 2:
205199
logger.debug(
206200
'In messages.dat database, removing an obsolete field from'
@@ -227,25 +221,22 @@ def run(self):
227221

228222
# Add a new column to the inventory table to store tags.
229223
item = '''SELECT value FROM settings WHERE key='version';'''
230-
parameters = ''
231-
self.cur.execute(item, parameters)
224+
self.cur.execute(item)
232225
currentVersion = int(self.cur.fetchall()[0][0])
233226
if currentVersion == 1 or currentVersion == 3:
234227
logger.debug(
235228
'In messages.dat database, adding tag field to'
236229
' the inventory table.')
237230
item = '''ALTER TABLE inventory ADD tag blob DEFAULT '' '''
238-
parameters = ''
239-
self.cur.execute(item, parameters)
231+
self.cur.execute(item)
240232
item = '''update settings set value=? WHERE key='version';'''
241233
parameters = (4,)
242234
self.cur.execute(item, parameters)
243235

244236
# Add a new column to the pubkeys table to store the address version.
245237
# We're going to trash all of our pubkeys and let them be redownloaded.
246238
item = '''SELECT value FROM settings WHERE key='version';'''
247-
parameters = ''
248-
self.cur.execute(item, parameters)
239+
self.cur.execute(item)
249240
currentVersion = int(self.cur.fetchall()[0][0])
250241
if currentVersion == 4:
251242
self.cur.execute('''DROP TABLE pubkeys''')
@@ -261,8 +252,7 @@ def run(self):
261252
# Add a new table: objectprocessorqueue with which to hold objects
262253
# that have yet to be processed if the user shuts down Bitmessage.
263254
item = '''SELECT value FROM settings WHERE key='version';'''
264-
parameters = ''
265-
self.cur.execute(item, parameters)
255+
self.cur.execute(item)
266256
currentVersion = int(self.cur.fetchall()[0][0])
267257
if currentVersion == 5:
268258
self.cur.execute('''DROP TABLE knownnodes''')
@@ -277,8 +267,7 @@ def run(self):
277267
# In table inventory and objectprocessorqueue, objecttype is now
278268
# an integer (it was a human-friendly string previously)
279269
item = '''SELECT value FROM settings WHERE key='version';'''
280-
parameters = ''
281-
self.cur.execute(item, parameters)
270+
self.cur.execute(item)
282271
currentVersion = int(self.cur.fetchall()[0][0])
283272
if currentVersion == 6:
284273
logger.debug(
@@ -303,8 +292,7 @@ def run(self):
303292
# clear it, and the pubkeys from inventory, so that they'll
304293
# be re-downloaded.
305294
item = '''SELECT value FROM settings WHERE key='version';'''
306-
parameters = ''
307-
self.cur.execute(item, parameters)
295+
self.cur.execute(item)
308296
currentVersion = int(self.cur.fetchall()[0][0])
309297
if currentVersion == 7:
310298
logger.debug(
@@ -327,16 +315,14 @@ def run(self):
327315
# the message signature. We'll use this as temporary message UUID
328316
# in order to detect duplicates.
329317
item = '''SELECT value FROM settings WHERE key='version';'''
330-
parameters = ''
331-
self.cur.execute(item, parameters)
318+
self.cur.execute(item)
332319
currentVersion = int(self.cur.fetchall()[0][0])
333320
if currentVersion == 8:
334321
logger.debug(
335322
'In messages.dat database, adding sighash field to'
336323
' the inbox table.')
337324
item = '''ALTER TABLE inbox ADD sighash blob DEFAULT '' '''
338-
parameters = ''
339-
self.cur.execute(item, parameters)
325+
self.cur.execute(item)
340326
item = '''update settings set value=? WHERE key='version';'''
341327
parameters = (9,)
342328
self.cur.execute(item, parameters)
@@ -345,8 +331,7 @@ def run(self):
345331
# can combine the pubkeyretrynumber and msgretrynumber into one.
346332

347333
item = '''SELECT value FROM settings WHERE key='version';'''
348-
parameters = ''
349-
self.cur.execute(item, parameters)
334+
self.cur.execute(item)
350335
currentVersion = int(self.cur.fetchall()[0][0])
351336
if currentVersion == 9:
352337
logger.info(
@@ -406,8 +391,7 @@ def run(self):
406391

407392
# Update the address colunm to unique in addressbook table
408393
item = '''SELECT value FROM settings WHERE key='version';'''
409-
parameters = ''
410-
self.cur.execute(item, parameters)
394+
self.cur.execute(item)
411395
currentVersion = int(self.cur.fetchall()[0][0])
412396
if currentVersion == 10:
413397
logger.debug(
@@ -470,8 +454,7 @@ def run(self):
470454
# Let us check to see the last time we vaccumed the messages.dat file.
471455
# If it has been more than a month let's do it now.
472456
item = '''SELECT value FROM settings WHERE key='lastvacuumtime';'''
473-
parameters = ''
474-
self.cur.execute(item, parameters)
457+
self.cur.execute(item)
475458
queryreturn = self.cur.fetchall()
476459
for row in queryreturn:
477460
value, = row
@@ -643,5 +626,5 @@ def create_function(self):
643626
self.conn.create_function("enaddr", 3, func=encodeAddress, deterministic=True)
644627
except (TypeError, sqlite3.NotSupportedError) as err:
645628
logger.debug(
646-
"Got error while pass deterministic in sqlite create function {}, Passing 3 params".format(err))
629+
"Got error while pass deterministic in sqlite create function %s, Passing 3 params", err)
647630
self.conn.create_function("enaddr", 3, encodeAddress)

0 commit comments

Comments
 (0)