diff --git a/baseline-refaster-rules/src/main/java/com/palantir/baseline/refaster/AssertjIsOne.java b/baseline-refaster-rules/src/main/java/com/palantir/baseline/refaster/AssertjIsOne.java deleted file mode 100644 index 2b13c6852..000000000 --- a/baseline-refaster-rules/src/main/java/com/palantir/baseline/refaster/AssertjIsOne.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.baseline.refaster; - -import com.google.errorprone.refaster.annotation.AfterTemplate; -import com.google.errorprone.refaster.annotation.BeforeTemplate; -import org.assertj.core.api.AbstractDoubleAssert; -import org.assertj.core.api.AbstractFloatAssert; -import org.assertj.core.api.AbstractIntegerAssert; -import org.assertj.core.api.AbstractLongAssert; -import org.assertj.core.api.NumberAssert; - -public final class AssertjIsOne { - - @BeforeTemplate - public AbstractIntegerAssert before(AbstractIntegerAssert input) { - return input.isEqualTo(1); - } - - @BeforeTemplate - public AbstractLongAssert before(AbstractLongAssert input) { - return input.isEqualTo(1L); - } - - @BeforeTemplate - public AbstractDoubleAssert before(AbstractDoubleAssert input) { - return input.isEqualTo(1D); - } - - @BeforeTemplate - public AbstractFloatAssert before(AbstractFloatAssert input) { - return input.isEqualTo(1f); - } - - @BeforeTemplate - public AbstractDoubleAssert beforeWithDecimal(AbstractDoubleAssert input) { - return input.isEqualTo(1.0D); - } - - @BeforeTemplate - public AbstractFloatAssert beforeWithDecimal(AbstractFloatAssert input) { - return input.isEqualTo(1.0); - } - - @AfterTemplate - public NumberAssert after(NumberAssert input) { - return input.isOne(); - } -} diff --git a/baseline-refaster-rules/src/test/java/com/palantir/baseline/refaster/AssertjIsOneTest.java b/baseline-refaster-rules/src/test/java/com/palantir/baseline/refaster/AssertjIsOneTest.java deleted file mode 100644 index 8f5a0d766..000000000 --- a/baseline-refaster-rules/src/test/java/com/palantir/baseline/refaster/AssertjIsOneTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (c) Copyright 2019 Palantir Technologies Inc. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.palantir.baseline.refaster; - -import static org.assertj.core.api.Assumptions.assumeThat; - -import org.junit.Test; - -public class AssertjIsOneTest { - - @Test - public void test() { - assumeThat(System.getProperty("java.specification.version")) - .describedAs("Refaster does not currently support fluent refactors on java 11") - .isEqualTo("1.8"); - RefasterTestHelper - .forRefactoring(AssertjIsOne.class) - .withInputLines( - "Test", - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in, int i, double d, float f, long l) {", - " assertThat(in.size()).isEqualTo(1);", - " assertThat(i).isEqualTo(1);", - " assertThat(d).isEqualTo(1);", - " assertThat(d).isEqualTo(1D);", - " assertThat(d).isEqualTo(1.0D);", - " assertThat(f).isEqualTo(1);", - " assertThat(f).isEqualTo(1.0);", - " assertThat(l).isEqualTo(1);", - " assertThat(l).isEqualTo(1L);", - " }", - "}") - .hasOutputLines( - "import static org.assertj.core.api.Assertions.assertThat;", - "import java.util.List;", - "public class Test {", - " void f(List in, int i, double d, float f, long l) {", - " assertThat(in.size()).isOne();", - " assertThat(i).isOne();", - " assertThat(d).isOne();", - " assertThat(d).isOne();", - " assertThat(d).isOne();", - " assertThat(f).isOne();", - " assertThat(f).isOne();", - " assertThat(l).isOne();", - " assertThat(l).isOne();", - " }", - "}"); - } - -} diff --git a/changelog/@unreleased/pr-917.v2.yml b/changelog/@unreleased/pr-917.v2.yml new file mode 100644 index 000000000..4d1d5867d --- /dev/null +++ b/changelog/@unreleased/pr-917.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Remove refaster AssertjIsOne rule. + links: + - https://github.com/palantir/gradle-baseline/pull/917