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.
"""
- 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 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
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,
- 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 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,
- 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 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)
- 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 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
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
- 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
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:
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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")
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")
Function __init__
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def __init__(self,
odpairs,
time_matrix,
horizon,
pickup_time=15,
Function print_solution
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def print_solution(demand,
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
- 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 __init__
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self,
Function csv_demand_output
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def csv_demand_output(demand,
Function csv_output
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def csv_output(demand,
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)
- 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 print_initial_solution
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def print_initial_solution(demand,