HazyResearch/numbskull

View on GitHub

Showing 154 of 497 total issues

Function generate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def generate(directory, propositions, voters_per_proposition, copies,
             FNULL):
    print("Generating " + directory + "...")
    sys.stdout.flush()

Severity: Minor
Found in experiments/tradeoff/generate.py - About 1 hr to fix

    Function generate has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def generate(directory, degree, copies):
        print("Generating " + directory + "...")
        sys.stdout.flush()
    
        try:
    Severity: Minor
    Found in experiments/intro/generate.py - About 1 hr to fix

      Function __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, weight, variable, factor, fmap, vmap,
      Severity: Major
      Found in numbskull/factorgraph.py - About 1 hr to fix

        Function add_ufo has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def add_ufo(factor, factor_pt, factor_ufo, fmap, vid, variable, var_pt, var_ufo, ufo_recv, pf_var_begin):
        Severity: Major
        Found in salt/src/messages.py - About 1 hr to fix

          Function find_ufo has 10 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def find_ufo(factor, factor_pt, factor_ufo, fmap, vid, variable, var_pt,
          Severity: Major
          Found in salt/src/messages.py - About 1 hr to fix

            Function process_ufo has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def process_ufo(factor, factor_pt, factor_ufo, fmap, vid, variable, var_pt, var_ufo, pf_ufo_var_list, pf_var_begin):
            Severity: Major
            Found in salt/src/messages.py - About 1 hr to fix

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

                  def loadFactorGraph(self, weight, variable, factor, fmap, domain_mask,
                                      edges, var_copies=1, weight_copies=1,
                                      factors_to_skip=np.empty(0, np.int64)):
                      """TODO."""
                      # Note: factors_to_skip must be sorted
              Severity: Minor
              Found in numbskull/numbskull.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 process_pf has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def process_pf(factor, factor_pt, factor_ufo, fmap, fid, vid, variable, var_pt, var_ufo, ismaster):
              Severity: Major
              Found in salt/src/messages.py - About 1 hr to fix

                Function process_ufo has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                def process_ufo(factor, factor_pt, factor_ufo, fmap, vid, variable, var_pt, var_ufo, pf_ufo_var_list, pf_var_begin):
                
                    time1 = time.time()
                    ufo_send, ufo_recv = find_ufo(factor, factor_pt.view(np.int8), factor_ufo, fmap, vid, variable, var_pt.view(np.int8), var_ufo, pf_ufo_var_list, pf_var_begin)
                    time2 = time.time()
                Severity: Minor
                Found in salt/src/messages.py - About 1 hr to fix

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

                  def find_pf(factor, factor_pt, factor_ufo, fmap, fid, vid, variable, var_pt, var_ufo):
                  Severity: Major
                  Found in salt/src/messages.py - About 1 hr to fix

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

                    def main(application_dir, machines, threads_per_machine,
                    Severity: Major
                    Found in salt/src/numbskull_master.py - About 1 hr to fix

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

                      def compute_ufo_values(factor, fmap, var_value, variable, var_ufo, ufo_send, ufo_start, ufo_map, ufo):
                      Severity: Major
                      Found in salt/src/messages.py - About 1 hr to fix

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

                        def get_factors_helper(row, fid, ff, factor, factor_pt, factor_ufo, fmap,
                        Severity: Major
                        Found in salt/src/messages.py - About 1 hr to fix

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

                              def loadFactorGraph(self, weight, variable, factor, fmap, domain_mask,
                          Severity: Major
                          Found in numbskull/numbskull.py - About 1 hr to fix

                            Function __init__ has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def __init__(self, weight, variable, factor, fmap, vmap,
                                             factor_index, var_copies, weight_copies, fid, workers):
                                    """TODO."""
                                    self.weight = weight
                                    self.variable = variable
                            Severity: Minor
                            Found in numbskull/factorgraph.py - About 1 hr to fix

                              Function find_pf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def find_pf(factor, factor_pt, factor_ufo, fmap, fid, vid, variable, var_pt, var_ufo):
                                  count = 0
                                  for i in range(len(factor)):
                                      if ((factor_pt[i] == 68 and not factor_ufo[i])  # "D"
                                        or factor_pt[i] == 71):  # "G"
                              Severity: Minor
                              Found in salt/src/messages.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 generate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                              Open

                              def generate(directory, propositions, voters_per_proposition, copies,
                                           FNULL):
                                  print("Generating " + directory + "...")
                                  sys.stdout.flush()
                              
                              
                              Severity: Minor
                              Found in experiments/tradeoff/generate.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 client has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              def client(argv=None):
                                  """TODO."""
                                  parser = argparse.ArgumentParser(
                                      description="Run Gibbs worker",
                                      epilog="")
                              Severity: Minor
                              Found in numbskull/distributed.py - About 1 hr to fix

                                Function loadFGFromFile has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def loadFGFromFile(self, directory=None, metafile=None, weightfile=None,
                                Severity: Major
                                Found in numbskull/numbskull.py - About 1 hr to fix

                                  Function eval_factor has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                  def eval_factor(factor_id, var_samp, value, var_copy, variable, factor, fmap,
                                  Severity: Major
                                  Found in numbskull/inference.py - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language