Skip to content

Commit 20e98fc

Browse files
Hasenncclauss
andauthored
Fix some warnings from LGTM (TheAlgorithms#2420)
* fix assignment of a variable to itself * Fix unnecessary 'else' clause in loop * formatting and redundant reasignment fix * mark unreachable code with a TODO comment * fix variable defined multiple times * fix static method without static decorator * revert unintended autoformatting Co-authored-by: Christian Clauss <[email protected]> * revert autoformatting issue * applied black autoformatting Co-authored-by: Christian Clauss <[email protected]>
1 parent f754c0d commit 20e98fc

6 files changed

+9
-6
lines changed

ciphers/enigma_machine2.py

-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ def enigma(
218218
rotorpos1 -= 1
219219
rotorpos2 -= 1
220220
rotorpos3 -= 1
221-
plugboard = plugboard
222221

223222
result = []
224223

graphs/directed_and_undirected_(weighted)_graph.py

+3
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def has_cycle(self):
226226
break
227227
else:
228228
return True
229+
# TODO:The following code is unreachable.
229230
anticipating_nodes.add(stack[len_stack_minus_one])
230231
len_stack_minus_one -= 1
231232
if visited.count(node[1]) < 1:
@@ -453,6 +454,8 @@ def has_cycle(self):
453454
break
454455
else:
455456
return True
457+
# TODO: the following code is unreachable
458+
# is this meant to be called in the else ?
456459
anticipating_nodes.add(stack[len_stack_minus_one])
457460
len_stack_minus_one -= 1
458461
if visited.count(node[1]) < 1:

graphs/minimum_spanning_tree_boruvka.py

+1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def union(self, item1, item2):
146146
self.parent[root2] = root1
147147
return root1
148148

149+
@staticmethod
149150
def boruvka_mst(graph):
150151
"""
151152
Implementation of Boruvka's algorithm

maths/chudnovsky_algorithm.py

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def pi(precision: int) -> str:
4444
getcontext().prec = precision
4545
num_iterations = ceil(precision / 14)
4646
constant_term = 426880 * Decimal(10005).sqrt()
47-
multinomial_term = 1
4847
exponential_term = 1
4948
linear_term = 13591409
5049
partial_sum = Decimal(linear_term)

other/triplet_sum.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ def triplet_sum2(arr: List[int], target: int) -> Tuple[int, int, int]:
6161
left += 1
6262
elif arr[i] + arr[left] + arr[right] > target:
6363
right -= 1
64-
else:
65-
return (0, 0, 0)
64+
return (0, 0, 0)
6665

6766

6867
def solution_times() -> Tuple[float, float]:

scheduling/shortest_job_first.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
def calculate_waitingtime(
1212
arrival_time: List[int], burst_time: List[int], no_of_processes: int
1313
) -> List[int]:
14-
1514
"""
1615
Calculate the waiting time of each processes
1716
Return: list of waiting times.
@@ -126,13 +125,16 @@ def calculate_average_times(
126125
for i in range(no_of_processes):
127126
print("Enter the arrival time and brust time for process:--" + str(i + 1))
128127
arrival_time[i], burst_time[i] = map(int, input().split())
128+
129129
waiting_time = calculate_waitingtime(arrival_time, burst_time, no_of_processes)
130+
130131
bt = burst_time
131132
n = no_of_processes
132133
wt = waiting_time
133134
turn_around_time = calculate_turnaroundtime(bt, n, wt)
135+
134136
calculate_average_times(waiting_time, turn_around_time, no_of_processes)
135-
processes = list(range(1, no_of_processes + 1))
137+
136138
fcfs = pd.DataFrame(
137139
list(zip(processes, burst_time, arrival_time, waiting_time, turn_around_time)),
138140
columns=[

0 commit comments

Comments
 (0)