From 3520205a3e5f92c47722bb547eb4ea41dfb30b71 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 11 Jul 2024 14:58:01 -0400 Subject: [PATCH] run haxelib formatter, and a handful of checkstyle changes --- checkstyle.json | 87 +----------------------------------------- hmm.json | 5 +++ hxformat.json | 3 +- source/BG.hx | 3 +- source/CBlock.hx | 3 +- source/CraneTrigger.hx | 2 +- source/Main.hx | 2 +- source/MenuState.hx | 3 +- source/Player.hx | 19 +++++---- source/Preloader.hx | 8 ++-- source/Sequence.hx | 6 ++- source/Splash.hx | 32 ++++++++-------- source/Walker.hx | 1 - 13 files changed, 53 insertions(+), 121 deletions(-) diff --git a/checkstyle.json b/checkstyle.json index 439f7bd..75aa8d5 100644 --- a/checkstyle.json +++ b/checkstyle.json @@ -25,7 +25,7 @@ "props": { "allowReturn": false, "allowFunction": false, - "allowCurlyBody": false, + "allowCurlyBody": true, "allowSingleArgParens": false } }, @@ -39,10 +39,6 @@ "type": "AvoidStarImport", "props": {} }, - { - "type": "AvoidTernaryOperator", - "props": {} - }, { "type": "BlockBreakingConditional", "props": {} @@ -61,10 +57,6 @@ "thresholdSimilar": 120 } }, - { - "type": "CommentedOutCode", - "props": {} - }, { "type": "ConditionalCompilation", "props": { @@ -72,27 +64,6 @@ "allowSingleline": true } }, - { - "type": "ConstantName", - "props": { - "severity": "IGNORE" - } - }, - { - "type": "CyclomaticComplexity", - "props": { - "thresholds": [ - { - "severity": "WARNING", - "complexity": 20 - }, - { - "severity": "ERROR", - "complexity": 25 - } - ] - } - }, { "type": "DefaultComesLast", "props": {} @@ -158,12 +129,6 @@ "atleast": [] } }, - { - "type": "FieldDocComment", - "props": { - "severity": "IGNORE" - } - }, { "type": "FileLength", "props": { @@ -271,13 +236,6 @@ "maxPublic": 100 } }, - { - "type": "MethodLength", - "props": { - "max": 50, - "ignoreEmptyLines": true - } - }, { "type": "MethodName", "props": { @@ -300,36 +258,16 @@ ] } }, - { - "type": "MultipleStringLiterals", - "props": { - "allowDuplicates": 2, - "minLength": 2, - "ignore": "^\\s+$" - } - }, { "type": "MultipleVariableDeclarations", "props": {} }, - { - "type": "NestedControlFlow", - "props": { - "max": 3 - } - }, { "type": "NestedForDepth", "props": { "max": 1 } }, - { - "type": "NestedIfDepth", - "props": { - "max": 1 - } - }, { "type": "NestedTryDepth", "props": { @@ -354,7 +292,7 @@ "boolOpPolicy": "around", "intervalOpPolicy": "none", "arrowPolicy": "around", - "arrowFunctionPolicy": "around", + "arrowFunctionPolicy": "ignore", "oldFunctionTypePolicy": "around", "newFunctionTypePolicy": "around" } @@ -402,15 +340,6 @@ "option": "eol" } }, - { - "type": "ParameterName", - "props": { - "format": "^(_|[a-z][a-zA-Z0-9]*$)", - "tokens": [], - "ignoreExtern": true, - "severity": "IGNORE" - } - }, { "type": "ParameterNumber", "props": { @@ -434,12 +363,6 @@ "prohibitMeta": false } }, - { - "type": "RedundantModifier", - "props": { - "severity": "IGNORE" - } - }, { "type": "Return", "props": { @@ -532,12 +455,6 @@ "ignorePattern": "^$" } }, - { - "type": "Trace", - "props": { - "severity": "IGNORE" - } - }, { "type": "TrailingWhitespace", "props": {} diff --git a/hmm.json b/hmm.json index 98f4cc5..608257b 100644 --- a/hmm.json +++ b/hmm.json @@ -10,6 +10,11 @@ "type": "haxelib", "version": "5.8.0" }, + { + "name": "formatter", + "type": "haxelib", + "version": "1.16.0" + }, { "name": "hmm", "type": "haxelib", diff --git a/hxformat.json b/hxformat.json index 4ddb9a6..46d16bc 100644 --- a/hxformat.json +++ b/hxformat.json @@ -8,10 +8,11 @@ "emptyCurly": "noBreak" }, "sameLine": { + "ifBody": "next", "ifElse": "next", "doWhile": "next", "tryBody": "next", "tryCatch": "next", - "elseBody": "same" + "elseBody": "next" } } diff --git a/source/BG.hx b/source/BG.hx index f688b20..e80db33 100644 --- a/source/BG.hx +++ b/source/BG.hx @@ -25,7 +25,8 @@ class BG extends FlxSprite x += FlxG.random.int(FlxG.width * 10, FlxG.width * 20); scrollFactor.x = FlxG.random.float(2, 5); } - else x += width * 2; + else + x += width * 2; } } } diff --git a/source/CBlock.hx b/source/CBlock.hx index 980d36b..e741dd0 100644 --- a/source/CBlock.hx +++ b/source/CBlock.hx @@ -36,7 +36,8 @@ class CBlock extends FlxTilemap { index = 2; } - else index = 1; + else + index = 1; mapData.push(index); } diff --git a/source/CraneTrigger.hx b/source/CraneTrigger.hx index 70a796b..9a601f0 100644 --- a/source/CraneTrigger.hx +++ b/source/CraneTrigger.hx @@ -16,7 +16,7 @@ class CraneTrigger extends FlxObject _p = P; } - override public function update(elapsed:Float):Void + override public function update(elapsed:Float) { if (overlaps(_p)) { diff --git a/source/Main.hx b/source/Main.hx index 254e23b..cb1c077 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -10,7 +10,7 @@ import openfl.display.Sprite; class Main extends Sprite { // Why can't Safari play .ogg in 2024.... :( - public static var SOUND_EXT:String = #if web ".mp3" #else ".ogg" #end; + public static final SOUND_EXT:String = #if web ".mp3" #else ".ogg" #end; #if web var framerate:Int = 60; diff --git a/source/MenuState.hx b/source/MenuState.hx index 54b14eb..539c564 100644 --- a/source/MenuState.hx +++ b/source/MenuState.hx @@ -68,7 +68,8 @@ class MenuState extends FlxState { if (FlxG.onMobile) notifString += ". Tap here to login"; - else notifString += ". Press N to login"; + else + notifString += ". Press N to login"; } new FlxTimer().start(4, _ -> diff --git a/source/Player.hx b/source/Player.hx index a1d03dd..55910f4 100644 --- a/source/Player.hx +++ b/source/Player.hx @@ -116,7 +116,8 @@ class Player extends FlxSprite acceleration.x = 20; else if (velocity.x < 600) acceleration.x = 10; - else acceleration.x = 4; + else + acceleration.x = 4; // Jumping jumpLimit = velocity.x / (maxVelocity.x * 2.5); @@ -146,7 +147,8 @@ class Player extends FlxSprite _craneFeet = false; if (_jump < 0.08) velocity.y = -maxVelocity.y * 0.65; - else velocity.y = -maxVelocity.y; + else + velocity.y = -maxVelocity.y; } // Animation @@ -165,7 +167,8 @@ class Player extends FlxSprite FlxG.sound.play("assets/sounds/footc" + FlxG.random.int(1, 4) + "" + Main.SOUND_EXT + ""); _craneFeet = false; } - else FlxG.sound.play("assets/sounds/foot" + FlxG.random.int(1, 4) + "" + Main.SOUND_EXT + ""); + else + FlxG.sound.play("assets/sounds/foot" + FlxG.random.int(1, 4) + "" + Main.SOUND_EXT + ""); } // Stumble / run animations @@ -179,7 +182,8 @@ class Player extends FlxSprite animation.play("run2"); else if (velocity.x < 600) animation.play("run3"); - else animation.play("run4"); + else + animation.play("run4"); } } else if (velocity.y < -140) @@ -202,7 +206,7 @@ class Player extends FlxSprite _my += FlxG.elapsed; } - public function stumble():Void + public function stumble() { FlxG.sound.play("assets/sounds/tumble" + Main.SOUND_EXT + ""); _stumble = true; @@ -212,10 +216,11 @@ class Player extends FlxSprite animation.play("stumble3", true); else if (velocity.x > 150) animation.play("stumble2", true); - else animation.play("stumble1", true); + else + animation.play("stumble1", true); } - public function craneFeet():Void + public function craneFeet() { _craneFeet = true; } diff --git a/source/Preloader.hx b/source/Preloader.hx index e86e4f8..babf6ce 100644 --- a/source/Preloader.hx +++ b/source/Preloader.hx @@ -34,7 +34,7 @@ class Preloader extends FlxBasePreloader super(MinDisplayTime, AllowedURLs); } - override function create():Void + override function create() { _buffer = new Sprite(); _buffer.scaleX = _buffer.scaleY = 2; @@ -74,7 +74,7 @@ class Preloader extends FlxBasePreloader * Cleanup your objects! * Make sure you call super.destroy()! */ - override function destroy():Void + override function destroy() { if (_buffer != null) { @@ -93,7 +93,7 @@ class Preloader extends FlxBasePreloader * Update is called every frame, passing the current percent loaded. Use this to change your loading bar or whatever. * @param Percent The percentage that the project is loaded */ - override public function update(Percent:Float):Void + override public function update(Percent:Float) { _bmpBar.scaleX = lerp(_bmpBar.scaleX, Percent, 0.1); prevPercentage = lerp(prevPercentage, Percent, 0.1); @@ -165,7 +165,7 @@ class Preloader extends FlxBasePreloader }, 600); } - function genNoise(Percent:Float):Void + function genNoise(Percent:Float) { noiseOverlay.lock(); for (i in 0...noiseOverlay.width) diff --git a/source/Sequence.hx b/source/Sequence.hx index 7ed459f..d1e7e7b 100644 --- a/source/Sequence.hx +++ b/source/Sequence.hx @@ -120,7 +120,8 @@ class Sequence extends FlxObject hallHeight = 5; else if (_player.velocity.x > 320) hallHeight = 4; - else hallHeight = 3; + else + hallHeight = 3; } // Figure out building position and dimensions @@ -302,7 +303,8 @@ class Sequence extends FlxObject { if (type == HALLWAY) _layer.add(new CBlock(Std.int(x), Std.int(y), Std.int(width), _tileSize, "assets/images/floor" + FlxG.random.int(1, 2) + ".png")); - else _layer.add(new CBlock(Std.int(x), Std.int(y), Std.int(width), _tileSize, "assets/images/roof" + FlxG.random.int(1, 5) + ".png")); + else + _layer.add(new CBlock(Std.int(x), Std.int(y), Std.int(width), _tileSize, "assets/images/roof" + FlxG.random.int(1, 5) + ".png")); _layer.add(new CBlock(Std.int(x), Std.int(y + _tileSize), Std.int(width), Std.int(height - _tileSize), wallPath)); diff --git a/source/Splash.hx b/source/Splash.hx index 2a723ff..ad76979 100644 --- a/source/Splash.hx +++ b/source/Splash.hx @@ -19,14 +19,14 @@ import openfl.geom.ColorTransform; */ class Splash extends FlxState { - static inline var BG_COLOR:FlxColor = 0xFF35353d; - static inline var GREEN:FlxColor = 0xFF00b922; - static inline var YELLOW:FlxColor = 0xFFffc132; - static inline var RED:FlxColor = 0xFFf5274e; - static inline var BLUE:FlxColor = 0xFF3641ff; - static inline var CYAN:FlxColor = 0xFF04cdfb; - - static final colors = [GREEN, YELLOW, RED, BLUE, CYAN]; + static inline final BG_COLOR:FlxColor = 0xFF35353d; + static inline final GREEN:FlxColor = 0xFF00b922; + static inline final YELLOW:FlxColor = 0xFFffc132; + static inline final RED:FlxColor = 0xFFf5274e; + static inline final BLUE:FlxColor = 0xFF3641ff; + static inline final CYAN:FlxColor = 0xFF04cdfb; + + static final colors:Array = [GREEN, YELLOW, RED, BLUE, CYAN]; static final shapes = [MIDDLE, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT]; var _logoTimer:Float = 0; @@ -132,7 +132,7 @@ class Splash extends FlxState _updateFunc(); } - static final times = [0.0, 0.2, 0.4, 0.6, 0.8, 1.5]; + static final times:Array = [0.0, 0.2, 0.4, 0.6, 0.8, 1.5]; /** When to change colors, in seconds, last is all white */ function updateColors() @@ -169,7 +169,7 @@ class Splash extends FlxState } } - inline function getStepColor(step:Int, colorIndex:Int) + inline function getStepColor(step:Int, colorIndex:Int):FlxColor { return if (step >= times.length) FlxColor.WHITE; else colors[(step + colorIndex) % colors.length]; } @@ -220,7 +220,7 @@ abstract LogoSprite(Sprite) to Sprite setColor(this.transform, FlxColor.interpolate(color1, color2, mix)); } - public function drawShape(shape:LogoShape):Void + public function drawShape(shape:LogoShape) { this.graphics.beginFill(0xFFffffff); switch shape @@ -239,7 +239,7 @@ abstract LogoSprite(Sprite) to Sprite this.graphics.endFill(); } - inline function drawMiddle():Void + inline function drawMiddle() { this.graphics.moveTo(-1, -37); this.graphics.lineTo(1, -37); @@ -252,7 +252,7 @@ abstract LogoSprite(Sprite) to Sprite this.graphics.lineTo(-1, -37); } - inline function drawTopLeft():Void + inline function drawTopLeft() { this.graphics.moveTo(-50, -50); this.graphics.lineTo(-25, -50); @@ -262,7 +262,7 @@ abstract LogoSprite(Sprite) to Sprite this.graphics.lineTo(-50, -50); } - inline function drawTopRight():Void + inline function drawTopRight() { this.graphics.moveTo(50, -50); this.graphics.lineTo(25, -50); @@ -272,7 +272,7 @@ abstract LogoSprite(Sprite) to Sprite this.graphics.lineTo(50, -50); } - inline function drawBottomLeft():Void + inline function drawBottomLeft() { this.graphics.moveTo(-50, 50); this.graphics.lineTo(-25, 50); @@ -282,7 +282,7 @@ abstract LogoSprite(Sprite) to Sprite this.graphics.lineTo(-50, 50); } - inline function drawBottomRight():Void + inline function drawBottomRight() { this.graphics.moveTo(50, 50); this.graphics.lineTo(25, 50); diff --git a/source/Walker.hx b/source/Walker.hx index f208160..ca57760 100644 --- a/source/Walker.hx +++ b/source/Walker.hx @@ -1,7 +1,6 @@ package; import flixel.effects.particles.FlxEmitter; -import flixel.group.FlxGroup; import flixel.FlxG; import flixel.FlxSprite;