projectpai/pouw-main-iteration

View on GitHub

Showing 93 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

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

    def get_waiting_tasks(page=1, per_page=20, redis_host='localhost', redis_port=6379):
        conn = redis.Redis(host=redis_host, port=redis_port)
        conn.ping()
    
        training_tasks = list(set([task.decode("utf-8").split('_')[2] for task in conn.keys('training_start_*')]))
    Severity: Major
    Found in pai/pouw/verification/task_info.py and 1 other location - About 1 day to fix
    pai/pouw/verification/task_info.py on lines 39..48

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 155.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    def get_started_tasks(page=1, per_page=20, redis_host='localhost', redis_port=6379):
        conn = redis.Redis(host=redis_host, port=redis_port)
        conn.ping()
    
        done_tasks = list(set([task.decode("utf-8").split('_')[2] for task in conn.keys('task_done_*')]))
    Severity: Major
    Found in pai/pouw/verification/task_info.py and 1 other location - About 1 day to fix
    pai/pouw/verification/task_info.py on lines 28..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 155.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    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

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

          navigation = Pagination.Navigation(self='page={}&per_page={}'.format(page, per_page),
                                             first='page=1&per_page={}'.format(per_page),
                                             previous='page={}&per_page={}'.format(1 if page == 1 else page - 1, per_page),
                                             next='page={}&per_page={}'.format(total_pages if page == total_pages
                                                                               else page + 1, per_page),
      Severity: Major
      Found in pai/pouw/verification/mock_utils.py and 1 other location - About 5 hrs to fix
      pai/pouw/verification/task_info.py on lines 176..181

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 95.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

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

          navigation = Pagination.Navigation(self='page={}&per_page={}'.format(page, per_page),
                                             first='page=1&per_page={}'.format(per_page),
                                             previous='page={}&per_page={}'.format(1 if page == 1 else page - 1, per_page),
                                             next='page={}&per_page={}'.format(total_pages if page == total_pages
                                                                               else page + 1, per_page),
      Severity: Major
      Found in pai/pouw/verification/task_info.py and 1 other location - About 5 hrs to fix
      pai/pouw/verification/mock_utils.py on lines 36..41

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 95.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

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

                @staticmethod
                def GetCompletedTasks(request,
                        target,
                        options=(),
                        channel_credentials=None,
            Severity: Major
            Found in pai/pouw/verification/task_info_pb2_grpc.py and 5 other locations - About 2 hrs to fix
            pai/pouw/verification/task_info_pb2_grpc.py on lines 115..130
            pai/pouw/verification/task_info_pb2_grpc.py on lines 132..147
            pai/pouw/verification/task_info_pb2_grpc.py on lines 166..181
            pai/pouw/verification/task_info_pb2_grpc.py on lines 183..198
            pai/pouw/verification/verifier_pb2_grpc.py on lines 54..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                @staticmethod
                def Verify(request,
                        target,
                        options=(),
                        channel_credentials=None,
            Severity: Major
            Found in pai/pouw/verification/verifier_pb2_grpc.py and 5 other locations - About 2 hrs to fix
            pai/pouw/verification/task_info_pb2_grpc.py on lines 115..130
            pai/pouw/verification/task_info_pb2_grpc.py on lines 132..147
            pai/pouw/verification/task_info_pb2_grpc.py on lines 149..164
            pai/pouw/verification/task_info_pb2_grpc.py on lines 166..181
            pai/pouw/verification/task_info_pb2_grpc.py on lines 183..198

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                @staticmethod
                def GetTaskID(request,
                        target,
                        options=(),
                        channel_credentials=None,
            Severity: Major
            Found in pai/pouw/verification/task_info_pb2_grpc.py and 5 other locations - About 2 hrs to fix
            pai/pouw/verification/task_info_pb2_grpc.py on lines 115..130
            pai/pouw/verification/task_info_pb2_grpc.py on lines 132..147
            pai/pouw/verification/task_info_pb2_grpc.py on lines 149..164
            pai/pouw/verification/task_info_pb2_grpc.py on lines 166..181
            pai/pouw/verification/verifier_pb2_grpc.py on lines 54..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                @staticmethod
                def GetWaitingTasks(request,
                        target,
                        options=(),
                        channel_credentials=None,
            Severity: Major
            Found in pai/pouw/verification/task_info_pb2_grpc.py and 5 other locations - About 2 hrs to fix
            pai/pouw/verification/task_info_pb2_grpc.py on lines 132..147
            pai/pouw/verification/task_info_pb2_grpc.py on lines 149..164
            pai/pouw/verification/task_info_pb2_grpc.py on lines 166..181
            pai/pouw/verification/task_info_pb2_grpc.py on lines 183..198
            pai/pouw/verification/verifier_pb2_grpc.py on lines 54..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                @staticmethod
                def GetStartedTasks(request,
                        target,
                        options=(),
                        channel_credentials=None,
            Severity: Major
            Found in pai/pouw/verification/task_info_pb2_grpc.py and 5 other locations - About 2 hrs to fix
            pai/pouw/verification/task_info_pb2_grpc.py on lines 115..130
            pai/pouw/verification/task_info_pb2_grpc.py on lines 149..164
            pai/pouw/verification/task_info_pb2_grpc.py on lines 166..181
            pai/pouw/verification/task_info_pb2_grpc.py on lines 183..198
            pai/pouw/verification/verifier_pb2_grpc.py on lines 54..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                @staticmethod
                def GetTaskDetails(request,
                        target,
                        options=(),
                        channel_credentials=None,
            Severity: Major
            Found in pai/pouw/verification/task_info_pb2_grpc.py and 5 other locations - About 2 hrs to fix
            pai/pouw/verification/task_info_pb2_grpc.py on lines 115..130
            pai/pouw/verification/task_info_pb2_grpc.py on lines 132..147
            pai/pouw/verification/task_info_pb2_grpc.py on lines 149..164
            pai/pouw/verification/task_info_pb2_grpc.py on lines 183..198
            pai/pouw/verification/verifier_pb2_grpc.py on lines 54..69

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 57.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            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
                Severity
                Category
                Status
                Source
                Language