From 0e74b892e3dbfe8293e44e306d2e04238d5477f5 Mon Sep 17 00:00:00 2001 From: Thibault Czarniak Date: Thu, 12 Sep 2024 19:32:23 +0200 Subject: [PATCH] Modified ArraysEqual and ComparingFloatingPointTypes names --- .../{ArraysEquals.scala => ArrayEquals.scala} | 12 +-- .../fix/ComparingFloatingPointTypes.scala | 27 +++++++ .../scala/fix/ComparingFloatingTypes.scala | 27 ------- .../META-INF/services/scalafix.v1.Rule | 78 +++++++++---------- .../{ArraysEquals.scala => ArrayEquals.scala} | 4 +- ...cala => ComparingFloatingPointTypes.scala} | 4 +- 6 files changed, 76 insertions(+), 76 deletions(-) rename input/src/main/scala/fix/{ArraysEquals.scala => ArrayEquals.scala} (67%) create mode 100644 input/src/main/scala/fix/ComparingFloatingPointTypes.scala delete mode 100644 input/src/main/scala/fix/ComparingFloatingTypes.scala rename rules/src/main/scala/fix/{ArraysEquals.scala => ArrayEquals.scala} (92%) rename rules/src/main/scala/fix/{ComparingFloatingTypes.scala => ComparingFloatingPointTypes.scala} (90%) diff --git a/input/src/main/scala/fix/ArraysEquals.scala b/input/src/main/scala/fix/ArrayEquals.scala similarity index 67% rename from input/src/main/scala/fix/ArraysEquals.scala rename to input/src/main/scala/fix/ArrayEquals.scala index e3be0c2..c621e55 100644 --- a/input/src/main/scala/fix/ArraysEquals.scala +++ b/input/src/main/scala/fix/ArrayEquals.scala @@ -1,17 +1,17 @@ /* -rule = ArraysEquals +rule = ArrayEquals */ package fix -object ArraysEquals { +object ArrayEquals { def test(): Unit = { val a = Array(1, 2, 3) val b = Array(1, 2, 3) - println(a == b) // assert: ArraysEquals - println(a != b) // assert: ArraysEquals + println(a == b) // assert: ArrayEquals + println(a != b) // assert: ArrayEquals - println(Array(1, 2, 3) == Array(1, 2, 3)) // assert: ArraysEquals - println(Array(1, 2, 3) != Array(1, 2, 3)) // assert: ArraysEquals + println(Array(1, 2, 3) == Array(1, 2, 3)) // assert: ArrayEquals + println(Array(1, 2, 3) != Array(1, 2, 3)) // assert: ArrayEquals // Null comparison shouldn't lead to warnings println(a != null) // scalafix: ok; diff --git a/input/src/main/scala/fix/ComparingFloatingPointTypes.scala b/input/src/main/scala/fix/ComparingFloatingPointTypes.scala new file mode 100644 index 0000000..7bd4bcb --- /dev/null +++ b/input/src/main/scala/fix/ComparingFloatingPointTypes.scala @@ -0,0 +1,27 @@ +/* +rule = ComparingFloatingPointTypes + */ +package fix + +object ComparingFloatingPointTypes { + def test(): Unit = { + val f1 = 1.46456f + val f2 = 1.46456f + if (f1 == f2) { // assert: ComparingFloatingPointTypes + print("Equal!") + } else { + print("Not equal") + } + val d1 = 1.546456 + val d2 = 1.546456 + if (d1 == d2) { // assert: ComparingFloatingPointTypes + print("Equal!") + } else { + print("Not equal!") + } + f1 == d1 // assert: ComparingFloatingPointTypes + f1.equals(f2) // assert: ComparingFloatingPointTypes + d1.equals(d2) // assert: ComparingFloatingPointTypes + } + +} diff --git a/input/src/main/scala/fix/ComparingFloatingTypes.scala b/input/src/main/scala/fix/ComparingFloatingTypes.scala deleted file mode 100644 index 05186d1..0000000 --- a/input/src/main/scala/fix/ComparingFloatingTypes.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* -rule = ComparingFloatingTypes - */ -package fix - -object ComparingFloatingTypes { - def test(): Unit = { - val f1 = 1.46456f - val f2 = 1.46456f - if (f1 == f2) { // assert: ComparingFloatingTypes - print("Equal!") - } else { - print("Not equal") - } - val d1 = 1.546456 - val d2 = 1.546456 - if (d1 == d2) { // assert: ComparingFloatingTypes - print("Equal!") - } else { - print("Not equal!") - } - f1 == d1 // assert: ComparingFloatingTypes - f1.equals(f2) // assert: ComparingFloatingTypes - d1.equals(d2) // assert: ComparingFloatingTypes - } - -} diff --git a/rules/src/main/resources/META-INF/services/scalafix.v1.Rule b/rules/src/main/resources/META-INF/services/scalafix.v1.Rule index b88dfbd..b155300 100644 --- a/rules/src/main/resources/META-INF/services/scalafix.v1.Rule +++ b/rules/src/main/resources/META-INF/services/scalafix.v1.Rule @@ -1,70 +1,70 @@ +fix.ArrayEquals fix.ArraysInFormat -fix.CatchNpe -fix.ComparingFloatingTypes -fix.EmptyInterpolatedString -fix.ImpossibleOptionSizeCondition -fix.IllegalFormatString -fix.IncorrectNumberOfArgsToFormat -fix.IncorrectlyNamedExceptions -fix.LonelySealedTrait -fix.MapGetAndGetOrElse -fix.NanComparison -fix.OptionGet -fix.OptionSize -fix.StripMarginOnRegex -fix.TryGet -fix.UnsafeTraversableMethods -fix.UnsafeContains -fix.UnsafeStringContains +fix.ArraysToString +fix.AsInstanceOf fix.AvoidSizeEqualsZero fix.AvoidSizeNotEqualsZero +fix.AvoidToMinusOne +fix.BigDecimalDoubleConstructor +fix.BigDecimalScaleWithoutRoundingMode +fix.BooleanParameter +fix.BoundedByFinalType +fix.BrokenOddness fix.CatchException fix.CatchExceptionImmediatelyRethrown fix.CatchFatal +fix.CatchNpe fix.CatchThrowable +fix.ClassNames fix.CollectionIndexOnNonIndexedSeq +fix.CollectionNamingConfusion fix.CollectionNegativeIndex fix.CollectionPromotionToAny +fix.ComparingFloatingPointTypes +fix.ComparisonToEmptyList +fix.ComparisonToEmptySet fix.ComparisonWithSelf fix.ConstantIf +fix.DivideByOne +fix.DoubleNegation fix.DuplicateImport +fix.DuplicateMapKey +fix.DuplicateSetValue +fix.EitherGet +fix.EmptyCaseClass fix.EmptyFor fix.EmptyIfBlock +fix.EmptyInterpolatedString fix.EmptyMethod fix.EmptySynchronizedBlock fix.EmptyTryBlock fix.EmptyWhileBlock fix.FinalizerWithoutSuper +fix.IllegalFormatString +fix.ImpossibleOptionSizeCondition +fix.IncorrectNumberOfArgsToFormat +fix.IncorrectlyNamedExceptions +fix.InterpolationToString +fix.LonelySealedTrait fix.LooksLikeInterpolatedString +fix.MapGetAndGetOrElse fix.MethodReturningAny +fix.NanComparison fix.NullAssignment +fix.NullParameter +fix.OptionGet +fix.OptionSize fix.RepeatedCaseBody fix.RepeatedIfElseBody +fix.StripMarginOnRegex fix.SwallowedException +fix.TryGet fix.UnnecessaryConversion fix.UnreachableCatch +fix.UnsafeContains +fix.UnsafeStringContains +fix.UnsafeTraversableMethods fix.UnusedMethodParameter fix.VarCouldBeVal fix.VariableShadowing -fix.WhileTrue -fix.InterpolationToString -fix.EitherGet -fix.NullParameter -fix.ArraysEquals -fix.ArraysToString -fix.AsInstanceOf -fix.AvoidToMinusOne -fix.BigDecimalDoubleConstructor -fix.BigDecimalScaleWithoutRoundingMode -fix.BooleanParameter -fix.BoundedByFinalType -fix.BrokenOddness -fix.ClassNames -fix.CollectionNamingConfusion -fix.ComparisonToEmptyList -fix.ComparisonToEmptySet -fix.DivideByOne -fix.DoubleNegation -fix.DuplicateMapKey -fix.DuplicateSetValue -fix.EmptyCaseClass \ No newline at end of file +fix.WhileTrue \ No newline at end of file diff --git a/rules/src/main/scala/fix/ArraysEquals.scala b/rules/src/main/scala/fix/ArrayEquals.scala similarity index 92% rename from rules/src/main/scala/fix/ArraysEquals.scala rename to rules/src/main/scala/fix/ArrayEquals.scala index 1c5c6b4..d315b44 100644 --- a/rules/src/main/scala/fix/ArraysEquals.scala +++ b/rules/src/main/scala/fix/ArrayEquals.scala @@ -1,5 +1,5 @@ /* -rule = ArraysEquals +rule = ArrayEquals */ package fix @@ -8,7 +8,7 @@ import scalafix.v1._ import scala.meta._ -class ArraysEquals extends SemanticRule("ArraysEquals") { +class ArrayEquals extends SemanticRule("ArrayEquals") { private def diag(pos: Position) = Diagnostic( "", diff --git a/rules/src/main/scala/fix/ComparingFloatingTypes.scala b/rules/src/main/scala/fix/ComparingFloatingPointTypes.scala similarity index 90% rename from rules/src/main/scala/fix/ComparingFloatingTypes.scala rename to rules/src/main/scala/fix/ComparingFloatingPointTypes.scala index 679d1c3..1ce9452 100644 --- a/rules/src/main/scala/fix/ComparingFloatingTypes.scala +++ b/rules/src/main/scala/fix/ComparingFloatingPointTypes.scala @@ -1,5 +1,5 @@ /* -rule = ComparingFloatingTypes +rule = ComparingFloatingPointTypes */ package fix @@ -8,7 +8,7 @@ import scalafix.lint.LintSeverity import scala.meta._ import scalafix.v1._ -class ComparingFloatingTypes extends SemanticRule("ComparingFloatingTypes") { +class ComparingFloatingPointTypes extends SemanticRule("ComparingFloatingPointTypes") { private def diag(pos: Position) = Diagnostic( "",