Showing 59 of 93 total issues
File task_info_pb2.py
has 802 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
# Generated by the protocol buffer compiler. DO NOT EDIT!
# source: task_info.proto
"""Generated protocol buffer code."""
from google.protobuf.internal import enum_type_wrapper
Function train
has a Cognitive Complexity of 71 (exceeds 5 allowed). Consider refactoring. Open
def train(self, training_samples, training_labels, validation_samples, validation_labels):
metrics = [0, 0, 0]
# ITERATIONS PHASE
for epoch in range(self.task_data['ml']['optimizer']['epochs']):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File worker.py
has 453 lines of code (exceeds 250 allowed). Consider refactoring. Open
import argparse
import binascii
import datetime
import json
import os.path
CommitteeCandidate
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class CommitteeCandidate:
def __init__(self, redis_host='localhost', redis_port=6379, is_debug=False):
self.conn = redis.Redis(host=redis_host, port=redis_port)
self.conn.ping()
Function verify_iteration
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def verify_iteration(msg_history_id, msg_id, nonce, block_header, redis_host='localhost', redis_port=6379):
print('\nVERIFY ITERATION(msg_history_id = %s, msg_id = %s, nonce = %s)' % (msg_history_id, msg_id, nonce))
ctx = mx.cpu()
conn = redis.Redis(host=redis_host, port=redis_port)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verify_iteration
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
def verify_iteration(msg_history_id, msg_id, nonce, block_header, redis_host='localhost', redis_port=6379):
print('\nVERIFY ITERATION(msg_history_id = %s, msg_id = %s, nonce = %s)' % (msg_history_id, msg_id, nonce))
ctx = mx.cpu()
conn = redis.Redis(host=redis_host, port=redis_port)
File committee_candidate.py
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
import abc
import argparse
import datetime
import functools
import logging
Function add
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def add(self, json, time_rcvd=None):
if time_rcvd is None: time_rcvd = _time()
if self.version:
return False
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File client.py
has 266 lines of code (exceeds 250 allowed). Consider refactoring. Open
import argparse
import datetime
import json
import logging
import os.path
File blkmaker.py
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
# Copyright 2012-2014 Luke Dashjr
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the standard MIT license. See COPYING for more details.
Trainer
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Trainer:
def __init__(self):
# add the default MNIST model
inputs = keras.Input(shape=(784,), name="digits")
x = layers.Dense(64, activation="relu", name="dense_1")(inputs)
Client
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Client:
# in this version we are using redis as a placeholder that will be replaced with blockchain in later versions
def __init__(self, redis_host='localhost', redis_port=6379, is_debug=False):
self.conn = None
Function main
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def main():
env = simpy.Environment()
miners = []
witnesses = []
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function pack_task_list
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def pack_task_list(task_ids, page, per_page, conn):
task_list = []
for task_id in task_ids:
task_details = get_task_full_info(task_id, conn)
if task_details is not None:
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function main
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def main():
parser = argparse.ArgumentParser(description='DKG simulation')
parser.add_argument('--task-id', type=str, default='default_task',
help='The task id')
parser.add_argument('--index', type=int, default=0,
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function get_completed_epochs
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_completed_epochs(conn, task_id):
epoch_details_list = []
scanned_epochs = set()
for epoch in conn.scan_iter('epoch_details_{}_*'.format(task_id)):
epoch_no = epoch.decode("utf-8").split('_')[3]
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verify_block_commitment
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def verify_block_commitment(conn, msg_id, worker_id, block_header):
msg_id_components = msg_id.split('_')
assert len(msg_id_components) == 5 and msg_id_components[0] == 'it' and msg_id_components[1] == 'res'
it_index = int(msg_id_components[4])
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function GetWaitingTasks
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def GetWaitingTasks(request,
Function Verify
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def Verify(request,
Function GetTaskID
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def GetTaskID(request,