Skip to content

Commit

Permalink
style: disable standard class signature for tests only
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasfara committed Dec 20, 2024
1 parent 59608bf commit 1603348
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[*.{kt,kts}]
indent_size = 4
max_line_length = 120
insert_final_newline = true

[**/*{t,T}est/kotlin/**.kt]
ktlint_standard_class-signature = disabled
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ import it.unibo.alchemist.model.Position
/**
* A program to be executed by a [CollektiveDevice], composed of a [name] and a [program] to be executed.
*/
data class CollektiveAlchemistProgram<P : Position<P>>(val name: String, val program: CollektiveDevice<P>.() -> Any?)
data class CollektiveAlchemistProgram<P : Position<P>>(
val name: String,
val program: CollektiveDevice<P>.() -> Any?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ class CollektiveDevice<P>(
private val environment: Environment<Any?, P>,
override val node: Node<Any?>,
private val retainMessagesFor: Time? = null,
) : NodeProperty<Any?>, Network<Int>, EnvironmentVariables, DistanceSensor where P : Position<P> {
private data class TimedMessage(val receivedAt: Time, val payload: InboundMessage<Int>)
) : NodeProperty<Any?>,
Network<Int>,
EnvironmentVariables,
DistanceSensor where P : Position<P> {
private data class TimedMessage(
val receivedAt: Time,
val payload: InboundMessage<Int>,
)

/**
* The current time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import org.slf4j.LoggerFactory
/**
* A message collector that logs messages using a SLF4J [logger].
*/
class SLF4JMessageCollector(val logger: Logger) : MessageCollector {
class SLF4JMessageCollector(
val logger: Logger,
) : MessageCollector {
override fun clear() = Unit

override fun hasErrors(): Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import org.jetbrains.kotlin.name.Name
* the IR using the function responsible for the alignment.
*/
@OptIn(UnsafeDuringIrConstructionAPI::class)
class AlignmentIrGenerationExtension(private val logger: MessageCollector) : IrGenerationExtension {
class AlignmentIrGenerationExtension(
private val logger: MessageCollector,
) : IrGenerationExtension {
override fun generate(
moduleFragment: IrModuleFragment,
pluginContext: IrPluginContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import org.jetbrains.kotlin.fir.analysis.extensions.FirAdditionalCheckersExtensi
/**
* Extension that adds a series of checkers that looks for missing align operations within the Collektive DSL.
*/
class MissingAlignExtension(session: FirSession) : FirAdditionalCheckersExtension(session) {
class MissingAlignExtension(
session: FirSession,
) : FirAdditionalCheckersExtension(session) {
override val expressionCheckers: ExpressionCheckers =
object : ExpressionCheckers() {
override val functionCallCheckers: Set<FirFunctionCallChecker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
* This visitor is used for functions that takes an aggregate argument, checking whether any aggregate call inside that
* function's body is used without a wrapping `alignedOn` call.
*/
class FunctionCallWithAggregateParVisitor(private val context: CheckerContext) : FirVisitorVoid() {
class FunctionCallWithAggregateParVisitor(
private val context: CheckerContext,
) : FirVisitorVoid() {
private var found = false
private var insideAlignedOn = false
private var functionCounter = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,7 @@ class YieldingContext<Initial, Return> {
/**
* Specifies the value [toSend] and the value [toReturn] of a yielding operator.
*/
data class YieldingResult<Initial, Return>(val toSend: Initial, val toReturn: Return)
data class YieldingResult<Initial, Return>(
val toSend: Initial,
val toReturn: Return,
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ sealed interface Message
/**
* [messages] received by a node from [senderId].
*/
data class InboundMessage<ID : Any>(val senderId: ID, val messages: Map<Path, *>) : Message
data class InboundMessage<ID : Any>(
val senderId: ID,
val messages: Map<Path, *>,
) : Message

/**
* An [OutboundMessage] are messages that a device [senderId] sends to all other neighbours.
Expand Down Expand Up @@ -76,4 +79,7 @@ class OutboundMessage<ID : Any>(
* Has a [default] value that is sent regardless the awareness the device's neighbours, [overrides] specifies the
* payload depending on the neighbours' values.
*/
data class SingleOutboundMessage<ID : Any, Payload>(val default: Payload, val overrides: Map<ID, Payload> = emptyMap())
data class SingleOutboundMessage<ID : Any, Payload>(
val default: Payload,
val overrides: Map<ID, Payload> = emptyMap(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package it.unibo.collektive.path.impl

import it.unibo.collektive.path.Path

internal data class PathImpl(private val path: List<Any?>) : Path {
internal data class PathImpl(
private val path: List<Any?>,
) : Path {
private val hash = path.hashCode()

override fun tokens(): List<Any?> = path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.gradle.api.provider.Property
* Creating gradle extension which is used to define a property that can be
* used to enable or disable the plugin.
*/
open class GradleExtension(objects: ObjectFactory) {
open class GradleExtension(
objects: ObjectFactory,
) {
/**
* Determines if the compiler plugin should be enabled or disabled.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import kotlin.random.Random
* An environment with a set of [nodes] mapped into [positions],
* which are considered connected if the [areConnected] function returns true for them.
*/
open class Environment<R>(val areConnected: (Environment<R>, Node<R>, Node<R>) -> Boolean = { _, _, _ -> true }) {
open class Environment<R>(
val areConnected: (Environment<R>, Node<R>, Node<R>) -> Boolean = { _, _, _ -> true },
) {
private val positions = mutableMapOf<Node<R>, Position>()
private val randomGenerator = Random(0)
private var nextId = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ package it.unibo.collektive.testing
/**
* An environment where nodes are connected if they are within [connectDistance] from each other.
*/
class EnvironmentWithMeshNetwork<R>(val connectDistance: Double) : Environment<R>(
{ thisEnv, a, b -> thisEnv.positionOf(a).distanceTo(thisEnv.positionOf(b)) <= connectDistance },
) {
override fun toString() = "Enviroment(connection=$connectDistance, nodes=$nodes)"
class EnvironmentWithMeshNetwork<R>(
val connectDistance: Double,
) : Environment<R>(
{ thisEnv, a, b -> thisEnv.positionOf(a).distanceTo(thisEnv.positionOf(b)) <= connectDistance },
) {
override fun toString() = "Environment(connection=$connectDistance, nodes=$nodes)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import kotlin.math.sqrt
/**
* A position in a 3D space with [x], [y], and [z] coordinates.
*/
data class Position(val x: Double, val y: Double, val z: Double) {
data class Position(
val x: Double,
val y: Double,
val z: Double,
) {
/**
* Returns the Euclidean distance between this position and [other].
*/
Expand Down

0 comments on commit 1603348

Please sign in to comment.