projectpai/pouw-main-iteration

View on GitHub

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
Severity: Major
Found in pai/pouw/verification/task_info_pb2.py - About 1 day to fix

    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']):
    Severity: Minor
    Found in pai/pouw/nodes/decentralized/worker.py - About 1 day to fix

    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
    Severity: Minor
    Found in pai/pouw/nodes/decentralized/worker.py - About 6 hrs to fix

      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()
      Severity: Minor
      Found in pai/pouw/nodes/decentralized/committee_candidate.py - About 3 hrs to fix

        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)
        Severity: Minor
        Found in pai/pouw/verification/verifier.py - About 3 hrs to fix

        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)
        Severity: Major
        Found in pai/pouw/verification/verifier.py - About 3 hrs to fix

          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
          Severity: Minor
          Found in pai/pouw/nodes/decentralized/committee_candidate.py - About 3 hrs to fix

            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
            
            
            Severity: Minor
            Found in pai/pouw/mining/blkmaker/blktemplate.py - About 2 hrs to fix

            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
            Severity: Minor
            Found in pai/pouw/nodes/decentralized/client.py - About 2 hrs to fix

              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.
              
              
              Severity: Minor
              Found in pai/pouw/mining/blkmaker/blkmaker.py - About 2 hrs to fix

                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)
                Severity: Minor
                Found in pai/pouw/nodes/decentralized/trainer.py - About 2 hrs to fix

                  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
                  Severity: Minor
                  Found in pai/pouw/nodes/decentralized/client.py - About 2 hrs to fix

                    Function main has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def main():
                        env = simpy.Environment()
                    
                        miners = []
                        witnesses = []
                    Severity: Minor
                    Found in pai/pouw/message_history/voting.py - About 2 hrs to fix

                    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:
                    Severity: Minor
                    Found in pai/pouw/verification/task_info.py - About 1 hr to fix

                    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,
                    Severity: Minor
                    Found in pai/pouw/dkg/distributed_joint_feldman.py - About 1 hr to fix

                    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]
                    Severity: Minor
                    Found in pai/pouw/verification/task_info.py - About 1 hr to fix

                    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])
                    
                    
                    Severity: Minor
                    Found in pai/pouw/verification/verifier.py - About 1 hr to fix

                    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,
                    Severity: Major
                    Found in pai/pouw/verification/task_info_pb2_grpc.py - About 1 hr to fix

                      Function Verify has 9 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def Verify(request,
                      Severity: Major
                      Found in pai/pouw/verification/verifier_pb2_grpc.py - About 1 hr to fix

                        Function GetTaskID has 9 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def GetTaskID(request,
                        Severity: Major
                        Found in pai/pouw/verification/task_info_pb2_grpc.py - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language