wglass/zoonado

View on GitHub

Showing 47 of 49 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@gen.coroutine
def run(client, args):
log.info("Launching %d workers.", args.workers)
yield client.start()
 
 
Severity: Major
Found in examples/election.py and 1 other location - About 4 hrs to fix
examples/locking.py on lines 21..32

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@gen.coroutine
def run(client, args):
log.info("Launching %d workers.", args.workers)
 
yield client.start()
Severity: Major
Found in examples/locking.py and 1 other location - About 4 hrs to fix
examples/election.py on lines 21..31

Similar blocks of code found in 4 locations. Consider refactoring.
Open

@gen.coroutine
def bloo(config):
while config.running.value == "yes":
log.info("[BLOO] doing work for %s seconds!", config.bloo.value)
yield gen.sleep(int(config.bloo.value))
Severity: Major
Found in examples/runtime_config.py and 3 other locations - About 3 hrs to fix
examples/runtime_config.py on lines 60..66
examples/runtime_config.py on lines 69..75
examples/runtime_config.py on lines 78..84

Similar blocks of code found in 4 locations. Consider refactoring.
Open

@gen.coroutine
def bazz(config):
while config.running.value == "yes":
log.info("[BAZZ] doing work for %s seconds!", config.bazz.value)
yield gen.sleep(int(config.bazz.value))
Severity: Major
Found in examples/runtime_config.py and 3 other locations - About 3 hrs to fix
examples/runtime_config.py on lines 60..66
examples/runtime_config.py on lines 69..75
examples/runtime_config.py on lines 87..93

Similar blocks of code found in 4 locations. Consider refactoring.
Open

@gen.coroutine
def bar(config):
while config.running.value == "yes":
log.info("[BAR] doing work for %s seconds!", config.bar.value)
yield gen.sleep(int(config.bar.value))
Severity: Major
Found in examples/runtime_config.py and 3 other locations - About 3 hrs to fix
examples/runtime_config.py on lines 60..66
examples/runtime_config.py on lines 78..84
examples/runtime_config.py on lines 87..93

Similar blocks of code found in 4 locations. Consider refactoring.
Open

@gen.coroutine
def foo(config):
while config.running.value == "yes":
log.info("[FOO] doing work for %s seconds!", config.foo.value)
yield gen.sleep(int(config.foo.value))
Severity: Major
Found in examples/runtime_config.py and 3 other locations - About 3 hrs to fix
examples/runtime_config.py on lines 69..75
examples/runtime_config.py on lines 78..84
examples/runtime_config.py on lines 87..93

Similar blocks of code found in 2 locations. Consider refactoring.
Open

@gen.coroutine
def acquire_write(self, timeout=None):
result = None
while not result:
try:
Severity: Major
Found in zoonado/recipes/shared_lock.py and 1 other location - About 2 hrs to fix
zoonado/recipes/lock.py on lines 10..21

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class Lock(BaseLock):
 
@gen.coroutine
def acquire(self, timeout=None):
result = None
Severity: Major
Found in zoonado/recipes/lock.py and 1 other location - About 2 hrs to fix
zoonado/recipes/shared_lock.py on lines 25..34

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class ResponseMeta(type):
 
def __new__(cls, name, bases, attrs):
new_class = super(ResponseMeta, cls).__new__(cls, name, bases, attrs)
 
 
Severity: Major
Found in zoonado/protocol/response.py and 1 other location - About 1 hr to fix
zoonado/exc.py on lines 43..52

Similar blocks of code found in 2 locations. Consider refactoring.
Open

class ResponseErrorMeta(type):
 
def __new__(cls, name, bases, attrs):
new_class = super(ResponseErrorMeta, cls).__new__(
cls, name, bases, attrs
Severity: Major
Found in zoonado/exc.py and 1 other location - About 1 hr to fix
zoonado/protocol/response.py on lines 11..18

Similar blocks of code found in 3 locations. Consider refactoring.
Open

def arguments(parser):
parser.add_argument(
"--workers", "-w", type=int, default=5,
help="Number of workers to launch."
)
Severity: Major
Found in examples/election.py and 2 other locations - About 1 hr to fix
examples/locking.py on lines 10..16
examples/party.py on lines 10..16

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def arguments(parser):
parser.add_argument(
"--path", "-b", type=str, default="/example-barrier",
help="ZNode path to use for the barrier."
)
Severity: Major
Found in examples/barrier.py and 1 other location - About 1 hr to fix
examples/counter.py on lines 11..17

Similar blocks of code found in 3 locations. Consider refactoring.
Open

def arguments(parser):
parser.add_argument(
"--workers", "-w", type=int, default=3,
help="Number of workers to launch."
)
Severity: Major
Found in examples/locking.py and 2 other locations - About 1 hr to fix
examples/election.py on lines 10..16
examples/party.py on lines 10..16

Similar blocks of code found in 3 locations. Consider refactoring.
Open

def arguments(parser):
parser.add_argument(
"--workers", "-w", type=int, default=5,
help="Number of workers to launch."
)
Severity: Major
Found in examples/party.py and 2 other locations - About 1 hr to fix
examples/election.py on lines 10..16
examples/locking.py on lines 10..16

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def arguments(parser):
parser.add_argument(
"--path", "-b", type=str, default="/example-counter",
help="ZNode path to use for the barrier."
)
Severity: Major
Found in examples/counter.py and 1 other location - About 1 hr to fix
examples/barrier.py on lines 9..15

Function find_server has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def find_server(self, allow_read_only):
conn = None
 
retry_policy = RetryPolicy.exponential_backoff(maximum=MAX_FIND_WAIT)
 
 
Severity: Minor
Found in zoonado/session.py - About 1 hr to fix

Function read_loop has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def read_loop(self):
"""
Infinite loop that reads messages off of the socket while not closed.
 
When a message is received its corresponding pending Future is set
Severity: Minor
Found in zoonado/connection.py - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

with (yield lock.acquire_read()):
log.info("[READER #%d] Got lock! Sleeping %d seconds", number, wait)
yield gen.sleep(wait)
log.info("[READER #%d] Done!", number)
Severity: Major
Found in examples/shared_locking.py and 1 other location - About 1 hr to fix
examples/shared_locking.py on lines 55..58

Similar blocks of code found in 2 locations. Consider refactoring.
Open

with (yield lock.acquire_write()):
log.info("[WRITER #%d] Got lock! Sleeping %d seconds", number, wait)
yield gen.sleep(wait)
log.info("[WRITER #%d] Done!", number)
Severity: Major
Found in examples/shared_locking.py and 1 other location - About 1 hr to fix
examples/shared_locking.py on lines 42..45

Function wait_in_line has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def wait_in_line(self, znode_label, timeout=None, blocked_by=None):
time_limit = None
if timeout is not None:
time_limit = time.time() + timeout
 
 
Severity: Minor
Found in zoonado/recipes/base_lock.py - About 1 hr to fix
Severity
Category
Status
Source
Language