mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
quick and dirty but working linter
This commit is contained in:
10
.idea/libraries/android_lint.xml
generated
10
.idea/libraries/android_lint.xml
generated
@@ -1,10 +0,0 @@
|
|||||||
<component name="libraryTable">
|
|
||||||
<library name="android-lint">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="file://$PROJECT_DIR$/lib/android-lint" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC />
|
|
||||||
<SOURCES />
|
|
||||||
<jarDirectory url="file://$PROJECT_DIR$/lib/android-lint" recursive="false" />
|
|
||||||
</library>
|
|
||||||
</component>
|
|
||||||
14
.idea/libraries/io_github_classgraph.xml
generated
Normal file
14
.idea/libraries/io_github_classgraph.xml
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="io.github.classgraph" type="repository">
|
||||||
|
<properties maven-id="io.github.classgraph:classgraph:4.8.157" />
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/classgraph-4.8.157.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/classgraph-4.8.157-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$PROJECT_DIR$/lib/classgraph-4.8.157-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
||||||
@@ -16,6 +16,6 @@
|
|||||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
<orderEntry type="library" name="jetbrains.kotlin.reflect" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlin.reflect" level="project" />
|
||||||
<orderEntry type="library" name="jetbrains.kotlin.test" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlin.test" level="project" />
|
||||||
<orderEntry type="library" name="android-lint" level="project" />
|
<orderEntry type="library" name="io.github.classgraph" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -24,6 +24,6 @@
|
|||||||
<orderEntry type="library" name="badlogicgames.gdx.backend.lwjgl3" level="project" />
|
<orderEntry type="library" name="badlogicgames.gdx.backend.lwjgl3" level="project" />
|
||||||
<orderEntry type="library" name="jetbrains.kotlin.reflect" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlin.reflect" level="project" />
|
||||||
<orderEntry type="library" name="jetbrains.kotlin.test" level="project" />
|
<orderEntry type="library" name="jetbrains.kotlin.test" level="project" />
|
||||||
<orderEntry type="library" name="android-lint" level="project" />
|
<orderEntry type="library" name="io.github.classgraph" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
BIN
lib/classgraph-4.8.157-javadoc.jar
LFS
Normal file
BIN
lib/classgraph-4.8.157-javadoc.jar
LFS
Normal file
Binary file not shown.
BIN
lib/classgraph-4.8.157-sources.jar
LFS
Normal file
BIN
lib/classgraph-4.8.157-sources.jar
LFS
Normal file
Binary file not shown.
BIN
lib/classgraph-4.8.157.jar
LFS
Normal file
BIN
lib/classgraph-4.8.157.jar
LFS
Normal file
Binary file not shown.
114
src/net/torvald/terrarum/QuickDirtyLint.kt
Normal file
114
src/net/torvald/terrarum/QuickDirtyLint.kt
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package net.torvald.terrarum
|
||||||
|
|
||||||
|
import io.github.classgraph.ClassGraph
|
||||||
|
import io.github.classgraph.ClassInfo
|
||||||
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.gameactors.Actor
|
||||||
|
import net.torvald.terrarum.gameitems.GameItem
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by minjaesong on 2023-05-22.
|
||||||
|
*/
|
||||||
|
fun main() {
|
||||||
|
|
||||||
|
val superClasses = listOf(
|
||||||
|
Actor::class.java,
|
||||||
|
GameItem::class.java
|
||||||
|
)
|
||||||
|
|
||||||
|
val serialisablePrimitives = listOf(
|
||||||
|
// comparison: exact match
|
||||||
|
"Z",
|
||||||
|
"B",
|
||||||
|
"S",
|
||||||
|
"I",
|
||||||
|
"J",
|
||||||
|
"F",
|
||||||
|
"D",
|
||||||
|
).flatMap { listOf(it, "[$it") }
|
||||||
|
|
||||||
|
val serialisableTypes = listOf(
|
||||||
|
// arrays: has '[' prepended
|
||||||
|
// comparison: startsWith
|
||||||
|
|
||||||
|
// primitives
|
||||||
|
"Ljava/lang/String", // includes ZipCodedStr
|
||||||
|
"Ljava/lang/Boolean",
|
||||||
|
"Ljava/lang/Byte",
|
||||||
|
"Ljava/lang/Short",
|
||||||
|
"Ljava/lang/Integer",
|
||||||
|
"Ljava/lang/Long",
|
||||||
|
"Ljava/lang/Float",
|
||||||
|
"Ljava/lang/Double",
|
||||||
|
// has serialiser on net.torvald.terrarum.serialise.Common
|
||||||
|
"Ljava/math/BigInteger",
|
||||||
|
"Ljava/util/UUID",
|
||||||
|
"Ljava/util/HashMap",
|
||||||
|
"Ljava/util/HashSet",
|
||||||
|
"Ljava/util/ArrayList",
|
||||||
|
"Lnet/torvald/terrarum/gameworld/BlockLayer",
|
||||||
|
"Lnet/torvald/terrarum/gameworld/WorldTime",
|
||||||
|
// complex types
|
||||||
|
"Lnet/torvald/gdx/graphics/Cvec",
|
||||||
|
"Lnet/torvald/random/HQRNG",
|
||||||
|
"Lnet/torvald/spriteanimation/SpriteAnimation",
|
||||||
|
"Lnet/torvald/terrarum/Codex",
|
||||||
|
"Lnet/torvald/terrarum/Point2d",
|
||||||
|
"Lnet/torvald/terrarum/Point2i",
|
||||||
|
"Lnet/torvald/terrarum/KVHashMap",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/Actor\$RenderOrder",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/ActorValue",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/Hitbox",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/Lightbox",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/PhysProperties",
|
||||||
|
"Lnet/torvald/terrarum/gameitems/GameItem",
|
||||||
|
"Lnet/torvald/terrarum/utils/HashArray",
|
||||||
|
"Lnet/torvald/terrarum/utils/HashedWirings",
|
||||||
|
"Lnet/torvald/terrarum/utils/HashedWiringGraph",
|
||||||
|
"Lnet/torvald/terrarum/utils/WiringGraphMap",
|
||||||
|
"Lnet/torvald/terrarum/savegame/ByteArray64",
|
||||||
|
"Lnet/torvald/terrarum/modulebasegame/gameactors/ActorInventory",
|
||||||
|
"Lnet/torvald/terrarum/modulebasegame/gameactors/BlockBox",
|
||||||
|
"Lnet/torvald/terrarum/modulebasegame/gameactors/FixtureInventory",
|
||||||
|
"Lkotlin/ranges/IntRange",
|
||||||
|
"Lorg/dyn4j/geometry/Vector2",
|
||||||
|
"Lcom/badlogic/gdx/graphics/Color",
|
||||||
|
// subclasses
|
||||||
|
"Lnet/torvald/terrarum/gameactors/BlockMarkerActor",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/Actor",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/ActorWithBody",
|
||||||
|
"Lnet/torvald/terrarum/gameactors/ActorHumanoid",
|
||||||
|
// composite types
|
||||||
|
"Lkotlin/Pair<Ljava/lang/Integer;Ljava/lang/Integer;>"
|
||||||
|
).flatMap { listOf(it, "[$it") }
|
||||||
|
|
||||||
|
val classaNonGrata = listOf(
|
||||||
|
"net.torvald.terrarum.modulebasegame.MovableWorldCamera"
|
||||||
|
)
|
||||||
|
|
||||||
|
ClassGraph().acceptPackages("net.torvald.terrarum")/*.verbose()*/.enableAllInfo().scan().let { scan ->
|
||||||
|
val offendingFields = scan.allClasses.filter { classinfo ->
|
||||||
|
superClasses.any { classinfo.extendsSuperclass(it) || classinfo.name == it.canonicalName } &&
|
||||||
|
!classaNonGrata.contains(classinfo.name)
|
||||||
|
}.flatMap { clazz ->
|
||||||
|
clazz.declaredFieldInfo.filter { field ->
|
||||||
|
!field.isTransient &&
|
||||||
|
!field.isEnum &&
|
||||||
|
!serialisablePrimitives.contains(field.typeSignatureOrTypeDescriptorStr) &&
|
||||||
|
serialisableTypes.none { field.typeSignatureOrTypeDescriptorStr.startsWith(it) } &&
|
||||||
|
!field.typeSignatureOrTypeDescriptorStr.endsWith("\$Companion;") &&
|
||||||
|
!field.className.contains("$") &&
|
||||||
|
!field.name.contains("$")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// println(offendingFields)
|
||||||
|
|
||||||
|
offendingFields.forEach {
|
||||||
|
println("\u001B[1m${it.name}\u001B[m\n\t\u001B[32mfrom: \u001B[m${it.className}\n\t\u001B[32mtype: \u001B[m${it.typeSignatureOrTypeDescriptorStr}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package net.torvald.terrarum
|
package net.torvald.terrarum
|
||||||
|
|
||||||
import com.android.tools.lint.client.api.IssueRegistry
|
/*import com.android.tools.lint.client.api.IssueRegistry
|
||||||
import com.android.tools.lint.client.api.UElementHandler
|
import com.android.tools.lint.client.api.UElementHandler
|
||||||
import com.android.tools.lint.detector.api.*
|
import com.android.tools.lint.detector.api.*
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
@@ -94,4 +94,4 @@ class TerrarumNonTransientUnserialisableType : Detector(), Detector.UastScanner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package net.torvald.terrarum.gameactors
|
package net.torvald.terrarum.gameactors
|
||||||
|
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
|
import net.torvald.terrarum.INGAME
|
||||||
import net.torvald.terrarum.ReferencingRanges
|
import net.torvald.terrarum.ReferencingRanges
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||||
import net.torvald.terrarum.savegame.toBigEndian
|
import net.torvald.terrarum.savegame.toBigEndian
|
||||||
import net.torvald.terrarum.utils.PasswordBase32
|
import net.torvald.terrarum.utils.PasswordBase32
|
||||||
@@ -82,6 +84,9 @@ abstract class Actor : Comparable<Actor>, Runnable {
|
|||||||
|
|
||||||
if (this is Pocketed)
|
if (this is Pocketed)
|
||||||
inventory.actor = this
|
inventory.actor = this
|
||||||
|
if (this is ActorHumanoid && vehicleRidingActorID != null) {
|
||||||
|
vehicleRiding = INGAME.getActorByID(vehicleRidingActorID!!) as Controllable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ import net.torvald.terrarum.itemproperties.Material
|
|||||||
import net.torvald.terrarum.langpack.Lang
|
import net.torvald.terrarum.langpack.Lang
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||||
|
import net.torvald.terrarum.savegame.ByteArray64
|
||||||
|
import net.torvald.terrarum.utils.HashArray
|
||||||
|
import net.torvald.terrarum.utils.ZipCodedStr
|
||||||
import org.dyn4j.geometry.Vector2
|
import org.dyn4j.geometry.Vector2
|
||||||
|
|
||||||
typealias ItemID = String
|
typealias ItemID = String
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
|||||||
this.physProp = physProp
|
this.physProp = physProp
|
||||||
}
|
}
|
||||||
|
|
||||||
var vehicleRiding: Controllable? = null // usually player only
|
@Transient internal var vehicleRiding: Controllable? = null // usually player only
|
||||||
|
var vehicleRidingActorID: ActorID? = null
|
||||||
|
|
||||||
|
|
||||||
/** Must be set by PlayerFactory */
|
/** Must be set by PlayerFactory */
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class ItemSwingingDoorOak(originalID: ItemID) :
|
|||||||
equipPosition = EquipPosition.HAND_GRIP
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
}
|
}
|
||||||
|
|
||||||
override val makeFixture: () -> FixtureBase = {
|
@Transient override val makeFixture: () -> FixtureBase = {
|
||||||
FixtureSwingingDoorOak()
|
FixtureSwingingDoorOak()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class ItemSwingingDoorEbony(originalID: ItemID) :
|
|||||||
equipPosition = EquipPosition.HAND_GRIP
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
}
|
}
|
||||||
|
|
||||||
override val makeFixture: () -> FixtureBase = {
|
@Transient override val makeFixture: () -> FixtureBase = {
|
||||||
FixtureSwingingDoorEbony()
|
FixtureSwingingDoorEbony()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ class ItemSwingingDoorBirch(originalID: ItemID) :
|
|||||||
equipPosition = EquipPosition.HAND_GRIP
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
}
|
}
|
||||||
|
|
||||||
override val makeFixture: () -> FixtureBase = {
|
@Transient override val makeFixture: () -> FixtureBase = {
|
||||||
FixtureSwingingDoorBirch()
|
FixtureSwingingDoorBirch()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ class ItemSwingingDoorRosewood(originalID: ItemID) :
|
|||||||
equipPosition = EquipPosition.HAND_GRIP
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
}
|
}
|
||||||
|
|
||||||
override val makeFixture: () -> FixtureBase = {
|
@Transient override val makeFixture: () -> FixtureBase = {
|
||||||
FixtureSwingingDoorRosewood()
|
FixtureSwingingDoorRosewood()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class ItemTapestry(originalID: ItemID) : FixtureItemBase(originalID, "net.torval
|
|||||||
equipPosition = EquipPosition.HAND_GRIP
|
equipPosition = EquipPosition.HAND_GRIP
|
||||||
}
|
}
|
||||||
|
|
||||||
override val makeFixture: () -> FixtureBase = {
|
@Transient override val makeFixture: () -> FixtureBase = {
|
||||||
FixtureTapestry(
|
FixtureTapestry(
|
||||||
Gdx.files.internal("assets/monkey_island").readBytes(),
|
Gdx.files.internal("assets/monkey_island").readBytes(),
|
||||||
Block.PLANK_NORMAL
|
Block.PLANK_NORMAL
|
||||||
|
|||||||
Reference in New Issue
Block a user