Skip to content

Commit 9efd21b

Browse files
CopilotbedaHovorkaclaude
committed
Cosmetic code review recommendations (#5)
* Initial plan * Address cosmetic code review recommendations Fix spelling errors: - Train.kt: getAccelaration → getAcceleration (3 occurrences) - Train.kt: accelaration → acceleration (8 occurrences) Improve documentation clarity: - SimulationContext.kt: "aPath" → "path" in javadoc - SimulationContext.kt: "dependly" → "depending" in javadoc - Doubleton.kt: "is not contain" → "is not contained" in exception message Simplify redundant condition: - Doubleton.kt: Remove redundant null check in constructor equality test All tests pass. Build successful. No functional changes. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Bedřich Hovorka <bedrich.hovorka@gmail.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7d29c3c commit 9efd21b

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/main/kotlin/cz/vutbr/fit/interlockSim/context/SimulationContext.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ interface SimulationContext : Context {
100100

101101
/**
102102
*
103-
* @param separator start of aPath
103+
* @param separator start of path
104104
* @param next first section
105105
* @return a path with all elements, or null if no path found
106106
*/
@@ -142,7 +142,7 @@ interface SimulationContext : Context {
142142
/**
143143
* @param nodeCell
144144
* @param current from, for determine direction
145-
* @return block, which follow dependly on node configuration, or null if no following block exists
145+
* @return block, which follow depending on node configuration, or null if no following block exists
146146
*/
147147
fun getNextTrackBlock(
148148
nodeCell: NodeCell,

src/main/kotlin/cz/vutbr/fit/interlockSim/sim/Train.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Train :
5050
override fun actions() {
5151
if (!started || !context.isReporting(ReportType.TRAIN_CONTINUOUS)) return // opti-hack
5252
val builder = StringBuilder()
53-
builder.append(getAccelaration()).append(' ')
53+
builder.append(getAcceleration()).append(' ')
5454
builder.append(getVelocity()).append(' ')
5555
builder.append(front.getTotalDistance()).append(' ')
5656
// builder.append(tail.getTotalDistance()).append(' ')
@@ -324,7 +324,7 @@ class Train :
324324
val semaphore: RailSemaphore = where
325325
semaphoreAction(semaphore, semaphore, current, next)
326326
} else if (where == timetable.getIn() && next != null) {
327-
assert(getAccelaration() != null)
327+
assert(getAcceleration() != null)
328328
semaphoreAction((where as InOut).getInSemaphore(), where, current, next)
329329
} else {
330330
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
@@ -444,7 +444,7 @@ class Train :
444444

445445
accelerate = false
446446
stop()
447-
accelaration.state = 0.0
447+
acceleration.state = 0.0
448448
}
449449

450450
private fun privateAccelerateTo(
@@ -520,7 +520,7 @@ class Train :
520520
if (velocity.state <= 0) velocity.state = 0.0
521521

522522
val a: Double = ((targetSpeed - velocity.state) * (targetSpeed + velocity.state)) / (2 * s)
523-
accelaration.state =
523+
acceleration.state =
524524
if (currentCondition!!.getStopTest().isDecelarate()) {
525525
Math.max(a, this@Train.MINIMAL_DECELERATION.toDouble())
526526
} else {
@@ -529,9 +529,9 @@ class Train :
529529
}
530530
}
531531

532-
private val accelaration: Variable = Variable(0.0)
532+
private val acceleration: Variable = Variable(0.0)
533533
private val velocity: Variable = Variable(0.0)
534-
private val va: SimpleIntegration = SimpleIntegration(velocity, accelaration)
534+
private val va: SimpleIntegration = SimpleIntegration(velocity, acceleration)
535535
private val front: Front = Front()
536536
private val tail: Tail = Tail()
537537
private val motor: Motor = Motor()
@@ -608,7 +608,7 @@ class Train :
608608
/**
609609
* @return current acceleration of train
610610
*/
611-
fun getAccelaration(): Double = accelaration.state
611+
fun getAcceleration(): Double = acceleration.state
612612

613613
/**
614614
* @return current speed of train
@@ -626,20 +626,20 @@ class Train :
626626
override fun nextSemaphore(): OrientedPathSeparator? = pathToSemaphore?.getLast()
627627

628628
override fun start(): Train {
629-
accelaration.start()
629+
acceleration.start()
630630
velocity.start()
631631
va.start()
632632
return this
633633
}
634634

635635
override fun stop() {
636-
accelaration.stop()
636+
acceleration.stop()
637637
velocity.stop()
638638
va.stop()
639639
velocity.state = 0.0
640640
velocity.rate = 0.0
641-
accelaration.rate = 0.0
642-
accelaration.state = 0.0
641+
acceleration.rate = 0.0
642+
acceleration.state = 0.0
643643
}
644644

645645
override fun toString(): String = trainPrefix

src/main/kotlin/cz/vutbr/fit/interlockSim/util/Doubleton.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Doubleton<T, V> : AbstractSet<T> {
8080
* @param second
8181
*/
8282
constructor(first: T, second: T) {
83-
if (first == second || (first != null && first == second)) throw IllegalArgumentException("arguments is equal")
83+
if (first == second) throw IllegalArgumentException("arguments is equal")
8484
this.first = first
8585
this.second = second
8686
}
@@ -130,7 +130,7 @@ class Doubleton<T, V> : AbstractSet<T> {
130130
return firstValue
131131
}
132132
if (secondEq) return secondValue
133-
throw IllegalArgumentException("Key $key is not contain in set")
133+
throw IllegalArgumentException("Key $key is not contained in set")
134134
}
135135

136136
private fun nullEq(

0 commit comments

Comments
 (0)