jmarca/initial-solution

View on GitHub

Showing 40 of 40 total issues

Function insert_nodes_for_breaks has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

    def insert_nodes_for_breaks(self,travel_times):
        """Use travel time matrix, pickup and dropoff pairs to create the
        necessary dummy nodes for modeling breaks between pairs of nodes.

        """
Severity: Minor
Found in src/demand.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 solution_output.py has 451 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Solution output routines"""
from six.moves import xrange
from datetime import datetime, timedelta
import pandas as pd
import math
Severity: Minor
Found in src/solution_output.py - About 6 hrs to fix

    Function print_solution has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    def print_solution(demand,
                       dist_matrix,
                       time_matrix,
                       vehicles,
                       manager,
    Severity: Minor
    Found in src/solution_output.py - About 6 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 csv_demand_output has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

    def csv_demand_output(demand,
                          dist_matrix,
                          time_matrix,
                          vehicles,
                          manager,
    Severity: Minor
    Found in src/solution_output.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 initial_routes_no_breaks has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def initial_routes_no_breaks(demand,vehicles,time_matrix,
                       debug=False):
        # initial routes should be a list of nodes to visit, in node space
        # (not solver index space, not map space)
    
    
    Severity: Minor
    Found in src/initial_routes.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

    File demand.py has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import pandas as pd
    import numpy as np
    import breaks
    import break_node as BN
    import math
    Severity: Minor
    Found in src/demand.py - About 3 hrs to fix

      Function create_short_break_callback has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_short_break_callback(travel_minutes_matrix,
                                demand,
                                period,
                                break_time):
          """create a callback function for short_breaktime.  presumes that
      Severity: Minor
      Found in src/evaluators.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 3 locations. Consider refactoring.
      Open

              if o_sv != 0:
                  # again, from node is important, but here have to consider if
                  # moving from break to break
                  for d_idx in tmm_index[notna.loc[o_idx,:]]:
                      if o_idx != d_idx:
      Severity: Major
      Found in src/evaluators.py and 2 other locations - About 1 hr to fix
      src/evaluators.py on lines 95..97
      src/evaluators.py on lines 143..145

      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 47.

      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 3 locations. Consider refactoring.
      Open

              for d_idx in tmm_index[notna.loc[o_idx,:]]:
                  if o_idx != d_idx:
                      service_time[o_idx,d_idx] = o_sv
      Severity: Major
      Found in src/evaluators.py and 2 other locations - About 1 hr to fix
      src/evaluators.py on lines 143..145
      src/evaluators.py on lines 191..196

      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 47.

      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 3 locations. Consider refactoring.
      Open

              for d_idx in tmm_index[notna.loc[o_idx,:]]:
                  if o_idx != d_idx:
                      service_time[o_idx,d_idx] = o_sv
      Severity: Major
      Found in src/evaluators.py and 2 other locations - About 1 hr to fix
      src/evaluators.py on lines 95..97
      src/evaluators.py on lines 191..196

      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 47.

      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

      Function main has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def main():
          """Entry point of the program."""
          parser = argparse.ArgumentParser(description='Solve assignment of truck load routing problem, give hours of service rules and a specified list of origins and destinations')
          # parser.add_argument('--resume_file',type=str,dest='resumefile',
          #                     help="resume a failed solver run from this file")
      Severity: Minor
      Found in src/run_initial_routes.py - About 1 hr to fix

        Function main has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def main():
            """Entry point of the program."""
            parser = argparse.ArgumentParser(description='Solve assignment of truck load routing problem, with specified list of origins and destinations, ignoring hours of service rules')
            # parser.add_argument('--resume_file',type=str,dest='resumefile',
            #                     help="resume a failed solver run from this file")
        Severity: Minor
        Found in src/run_without_constraints.py - About 1 hr to fix

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

              def __init__(self,
                           odpairs,
                           time_matrix,
                           horizon,
                           pickup_time=15,
          Severity: Minor
          Found in src/demand.py - About 1 hr to fix

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

            def print_solution(demand,
            Severity: Major
            Found in src/solution_output.py - About 1 hr to fix

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

              def create_drive_callback(travel_minutes_matrix,
                                        demand,
                                        period,
                                        break_time):
                  """create a callback function for drivetime.  presumes that
              Severity: Minor
              Found in src/evaluators.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 __init__ has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self,
              Severity: Major
              Found in src/break_node.py - About 1 hr to fix

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

                def csv_demand_output(demand,
                Severity: Major
                Found in src/solution_output.py - About 1 hr to fix

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

                  def csv_output(demand,
                  Severity: Major
                  Found in src/solution_output.py - About 1 hr to fix

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

                    def decide_next(d,t,accumulators,od):
                        # decide where to go next
                        # first, can get to goal?
                        if goal_okay(d,t,accumulators,od):
                            return move_to_goal(d,t,accumulators,od)
                    Severity: Minor
                    Found in src/initial_routes.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 print_initial_solution has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def print_initial_solution(demand,
                    Severity: Major
                    Found in src/solution_output.py - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language