Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bunch of build warnings #283

Closed
wants to merge 2 commits into from
Closed

Conversation

nreid260
Copy link
Contributor

No description provided.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 13, 2022
@nreid260
Copy link
Contributor Author

Looks like this depends on Guava 31

Copy link
Contributor

@cgrushko cgrushko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some build errors reported by CI

@nreid260 nreid260 force-pushed the fix_warnings branch 2 times, most recently from b770107 to 48de712 Compare February 14, 2022 08:51
@cgrushko
Copy link
Contributor

Java 13 still has failures - can you see the logs? (not sure about the permissions here)

@nreid260
Copy link
Contributor Author

I can see them, but I don't understand what would be different. Do you have a minute to take a look? The goal here is just to stop kotlinc from spamming so much.

@cgrushko
Copy link
Contributor

No idea; does it build successfully locally for you on Java 13?

@nreid260 nreid260 force-pushed the fix_warnings branch 6 times, most recently from c591025 to e88be9e Compare February 25, 2022 17:11
@nreid260
Copy link
Contributor Author

Looks like it was some kind of incompatibility with Guava 31

@nreid260
Copy link
Contributor Author

Poke

when {
length < 0 -> return EMPTY_RANGE
length == 0 -> 1 // 0 stands for "format the line under the cursor"
else -> length
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be else -> 1, at least to preserve the current behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should preserve the current behaviour. length = 1 isn't a case, it's the behaviour when length == 0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/facepalm

Comment on lines -137 to +142
val builder = ImmutableMap.builder<Int, Int>()
val builder = LinkedHashMap<Int, Int>()
for (tok in toks) {
builder.put(tok.position, tok.column)
}
return builder.build()
return ImmutableMap.copyOf(builder)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the build warning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImmutableMap.Builder.build() throws if there are are duplicate keys. This caused enough confusion that a preferred, explicit method buildOrThrow was added in Guava 31.0. Google builds from the newest version of Guava. https://guava.dev/releases/31.0.1-jre/api/docs/com/google/common/collect/ImmutableMap.Builder.html#build()

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. I think it's fine this time, but we'll keep running into these problems, since Meta / OSS isn't aware of Guava 31.
Don't know if policy allows that, but you may want to consider adding Guava 29 to third-party (and limiting its visibility to ktfmt).

@@ -148,7 +148,7 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<artifactId>kotlin-stdlib-jdk7</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the build warning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is needed for the changes to core/src/test/java/com/facebook/ktfmt/cli/MainTest.kt

@facebook-github-bot
Copy link
Contributor

@cgrushko has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines -127 to +136
for (element in name) {
if (!Character.isAlphabetic(element.toInt())) {
for (char in name) {
if (!Character.isAlphabetic(char.code)) {
continue
}
if (first) {
firstUppercase = Character.isUpperCase(element)
firstUppercase = Character.isUpperCase(char)
first = false
}
hasUppercase = hasUppercase or Character.isUpperCase(element)
hasLowercase = hasLowercase or Character.isLowerCase(element)
hasUppercase = hasUppercase or Character.isUpperCase(char)
hasLowercase = hasLowercase or Character.isLowerCase(char)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're changing this how about using the Kotlin extension methods?

Comment on lines -35 to +36
private val root = createTempDir()
private val root = createTempDirectory().toFile()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the issue here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createTempDir is marked deprecated

@@ -2069,7 +2069,7 @@ class FormatterTest {
deduceMaxWidth = true)

@Test
fun `handle ? for nullalble types`() =
fun `handle qmark for nullalble types`() =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"question mark" please

Let's avoid abbreviations for easier readability

@nreid260 nreid260 deleted the fix_warnings branch April 16, 2022 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants