Skip to content

Commit ca77656

Browse files
authored
Solve SONARcloud problems. (#869)
1 parent aee2a1a commit ca77656

File tree

10 files changed

+26
-26
lines changed

10 files changed

+26
-26
lines changed

doc/api/pydoc/build.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ def classify_class_attrs(cls):
9393
class DefaultFormatter(pydoc.HTMLDoc):
9494
def docmodule(self, object, name=None, mod=None, packageContext = None, *ignored):
9595
"""Produce HTML documentation for a module object."""
96-
name = object.__name__ # ignore the passed-in name
97-
parts = split(name, '.')
96+
my_name = object.__name__ # ignore the passed-in name
97+
parts = split(my_name, '.')
9898
links = []
9999
for i in range(len(parts)-1):
100100
links.append(
@@ -135,7 +135,7 @@ def docmodule(self, object, name=None, mod=None, packageContext = None, *ignored
135135
for base in value.__bases__:
136136
key, modname = base.__name__, base.__module__
137137
module = sys.modules.get(modname)
138-
if modname != name and module and hasattr(module, key):
138+
if modname != my_name and module and hasattr(module, key):
139139
if getattr(module, key) is base:
140140
if not cdict.has_key(key):
141141
cdict[key] = cdict[base] = modname + '.html#' + key
@@ -165,10 +165,10 @@ def docmodule(self, object, name=None, mod=None, packageContext = None, *ignored
165165
path = os.path.join(object.__path__[0], file)
166166
modname = inspect.getmodulename(file)
167167
if modname and modname not in modnames:
168-
modpkgs.append((modname, name, 0, 0))
168+
modpkgs.append((modname, my_name, 0, 0))
169169
modnames.append(modname)
170170
elif pydoc.ispackage(path):
171-
modpkgs.append((file, name, 1, 0))
171+
modpkgs.append((file, my_name, 1, 0))
172172
modpkgs.sort()
173173
contents = self.multicolumn(modpkgs, self.modpkglink)
174174
## result = result + self.bigsection(
@@ -184,15 +184,15 @@ def docmodule(self, object, name=None, mod=None, packageContext = None, *ignored
184184
if classes:
185185
#FIX classlist = map(lambda (key, value): value, classes)
186186
contents = [
187-
self.formattree(inspect.getclasstree(classlist, 1), name)]
187+
self.formattree(inspect.getclasstree(classlist, 1), my_name)]
188188
for key, value in classes:
189-
contents.append(self.document(value, key, name, fdict, cdict))
189+
contents.append(self.document(value, key, my_name, fdict, cdict))
190190
result = result + self.bigsection(
191191
'Classes', '#ffffff', '#ee77aa', join(contents))
192192
if funcs:
193193
contents = []
194194
for key, value in funcs:
195-
contents.append(self.document(value, key, name, fdict, cdict))
195+
contents.append(self.document(value, key, my_name, fdict, cdict))
196196
result = result + self.bigsection(
197197
'Functions', '#ffffff', '#eeaa77', join(contents))
198198
if data:

examples/common/async_tornado_client_serial.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ def callback(protocol, future): # pylint: disable=redefined-outer-name
159159
# ----------------------------------------------------------------------- #
160160

161161
# Rtu
162-
protocol, future = AsyncModbusSerialClient(schedulers.IO_LOOP, # pylint: disable=unpacking-non-sequence
162+
protocol, future = AsyncModbusSerialClient(schedulers.IO_LOOP, # NOSONAR pylint: disable=unpacking-non-sequence
163163
method="rtu",
164-
port="/tmp/ptyp0", #nosec
164+
port="/tmp/ptyp0", # nosec NOSONAR
165165
baudrate=9600,
166166
timeout=2)
167167

examples/common/async_twisted_client_serial.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# state a few constants
2020
# ---------------------------------------------------------------------------#
2121

22-
SERIAL_PORT = "/tmp/ptyp0" #nosec
22+
SERIAL_PORT = "/tmp/ptyp0" # nosec NOSONAR
2323
STATUS_REGS = (1, 2)
2424
STATUS_COILS = (1, 3)
2525
CLIENT_DELAY = 1

examples/contrib/asynchronous_asyncio_serial_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def make_protocol():
9999

100100
if __name__ == '__main__':
101101
loop = asyncio.get_event_loop()
102-
coro = create_serial_connection(loop, make_protocol, '/tmp/ttyp0', #nosec
102+
coro = create_serial_connection(loop, make_protocol, '/tmp/ttyp0', # nosec NOSONAR
103103
baudrate=9600)
104104
transport, protocol = loop.run_until_complete(asyncio.gather(coro))[0]
105105
loop.run_until_complete(start_async_test(protocol))

examples/contrib/concurrent_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# -------------------------------------------------------------------------- #
3030
log = logging.getLogger("pymodbus")
3131
log.setLevel(logging.DEBUG)
32-
logging.basicConfig()
32+
logging.basicConfig() # NOSONAR
3333

3434

3535
# -------------------------------------------------------------------------- #

examples/contrib/serial_forwarder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def run_serial_forwarder():
3131
# Note this would send the requests on the serial client with address = 0
3232

3333
# ----------------------------------------------------------------------- #
34-
client = ModbusClient(method='rtu', port='/tmp/ptyp0') #nosec
34+
client = ModbusClient(method='rtu', port='/tmp/ptyp0') # nosec NOSONAR
3535
# If required to communicate with a specified client use unit=<unit_id>
3636
# in RemoteSlaveContext
3737
# For e.g to forward the requests to slave with unit address 1 use

examples/contrib/sunspec_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ def __init__(self, payload, byteorder):
192192
.. note:: This is always set to big endian byte order
193193
as specified in the protocol.
194194
"""
195-
byteorder = Endian.Big
196-
BinaryPayloadDecoder.__init__(self, payload, byteorder)
195+
my_byteorder = Endian.Big
196+
BinaryPayloadDecoder.__init__(self, payload, my_byteorder)
197197

198198
def decode_string(self, size=1):
199199
""" Decodes a string from the buffer

test/test_client_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_callback(client): # pylint: disable=unused-argument
7070
@patch("pymodbus.client.asynchronous.tornado.IOStream")
7171
def test_tcp_tornado_client(self, mock_iostream, mock_ioloop): # pylint: disable=no-self-use,unused-argument
7272
""" Test the TCP tornado client client initialize """
73-
protocol, future = AsyncModbusTCPClient( # pylint: disable=unpacking-non-sequence
73+
protocol, future = AsyncModbusTCPClient( # NOSOANR pylint: disable=unpacking-non-sequence
7474
schedulers.IO_LOOP, framer=ModbusSocketFramer(ClientDecoder()))
7575
client = future.result()
7676
assert isinstance(client, AsyncTornadoModbusTcpClient) #nosec

test/test_client_async_asyncio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def test_initialization_serial_in_loop(self): # pylint: disable=no-self-use
113113
_, client = AsyncModbusSerialClient( #NOSONAR pylint: disable=unpacking-non-sequence
114114
schedulers.ASYNC_IO, port='/tmp/ptyp0', baudrate=9600, method='rtu') #NOSONAR #nosec
115115

116-
assert client.port == '/tmp/ptyp0' #nosec
116+
assert client.port == '/tmp/ptyp0' # nosec NOSONAR
117117
assert client.baudrate == 9600 #nosec
118118

119119
def test_factory_reset_wait_before_reconnect(self): # pylint: disable=no-self-use

test/test_device.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,24 +235,24 @@ def test_modbus_control_block_invalid_diagnostic(self):
235235

236236
def test_add_remove__single_clients(self):
237237
""" Test adding and removing a host """
238-
self.assertFalse(self.access.check("192.168.1.1"))
239-
self.access.add("192.168.1.1")
240-
self.assertTrue(self.access.check("192.168.1.1"))
241-
self.access.add("192.168.1.1")
242-
self.access.remove("192.168.1.1")
243-
self.assertFalse(self.access.check("192.168.1.1"))
238+
self.assertFalse(self.access.check("192.168.1.1")) # NOSONAR
239+
self.access.add("192.168.1.1") # NOSONAR
240+
self.assertTrue(self.access.check("192.168.1.1")) # NOSONAR
241+
self.access.add("192.168.1.1") # NOSONAR
242+
self.access.remove("192.168.1.1") # NOSONAR
243+
self.assertFalse(self.access.check("192.168.1.1")) # NOSONAR
244244

245245
def test_add_remove_multiple_clients(self):
246246
""" Test adding and removing a host """
247-
clients = ["192.168.1.1", "192.168.1.2", "192.168.1.3"]
247+
clients = ["192.168.1.1", "192.168.1.2", "192.168.1.3"] # NOSONAR
248248
self.access.add(clients)
249249
for host in clients:
250250
self.assertTrue(self.access.check(host))
251251
self.access.remove(clients)
252252

253253
def test_network_access_list_iterator(self):
254254
""" Test adding and removing a host """
255-
clients = ["127.0.0.1", "192.168.1.1", "192.168.1.2", "192.168.1.3"]
255+
clients = ["127.0.0.1", "192.168.1.1", "192.168.1.2", "192.168.1.3"] # NOSONAR
256256
self.access.add(clients)
257257
for host in self.access:
258258
self.assertTrue(host in clients)

0 commit comments

Comments
 (0)