question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Meaningless variable names

See original GitHub issue

Great plugin, I got some quite useless variable names though:

const val core_ktx: String = "androidx.core:core-ktx:" + Versions.core_ktx
const val core_kt: String = "ru.ztrap.iconics:core-kt:" + Versions.core_kt

They are both kotlin extensions but for very different libraries yet cant be distinguished by the variable name. As kt and ktx endings are quite common for such libraries maybe check for combinations of that and the meaningless words you already check against would be a good idea. Basically add a list of suffixes.

On the other hand some of the constants get very long:

const val jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin: String =
            "jmfayard.github.io.gradle-kotlin-dsl-libs:jmfayard.github.io.gradle-kotlin-dsl-libs.gradle.plugin:" + Versions.jmfayard_github_io_gradle_kotlin_dsl_libs_gradle_plugin

That’s the most extreme example I had in my projects. I’d suggest cutting common segments like github and TLDs from the name to get something like the following:

const val jmfayard_kotlin_dsl_libs_gradle_plugin: String =
            "jmfayard.github.io.gradle-kotlin-dsl-libs:jmfayard.github.io.gradle-kotlin-dsl-libs.gradle.plugin:" + Versions.jmfayard_gradle_kotlin_dsl_libs_gradle_plugin

Still long but better.

I can take a see if I can make a pull request with those changes in the next days. I’m of course open for better solutions, these are just my initial thoughts.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ivobergercommented, Dec 15, 2018

@IIIuminator it’s because if two libraries have the same name (here core-ktx), the plugin detects it and uses the FDQN for both. The “meaningless names” feature is that we don’t wait for the conflict to happen and always use the FDQN

yes of course. That helped me notice that I used the wrong version of the same library in one of the apps. Was already thinking something’s fishy 😄

What do you think?

sounds good to me. was thinking myself that being able to configure it might be the best solution. Using a config option it should be possible to remedy these really long names too. have a useFdqnFor and a removeFdqnFor option together with FdqnElements so its possible to configure whats removed.

0reactions
jmfayardcommented, Dec 16, 2018

That would be better but it needs to be interoperable with Groovy and so an Iterable was the simplest way to do that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Meaningless variable names - Peter Hilton
Meaningless variable names · val parrot1 = … val parrot2 = … · val deadParrot = … val replacement = … · val...
Read more >
Bad Variable Names to Avoid ‍♀️ | SamanthaMing.com
Bad Variable Names to Avoid ‍♀️. In an earlier post, I mentioned how you can give your boolean variables a better name by...
Read more >
Bad Variable Names - C2 wiki
A good variable name should indicate its use, like "ErrorMessage" or "InputBuffer". And if it has several different uses, you should probably split...
Read more >
Meaningless Variable Names
Although meaningful variable names can make reading code easier, they sometimes lead to mistakes and can make debugging difficult. Consider ...
Read more >
The world's two worst variable names : r/programming - Reddit
My favorite example in that classic is "Choose variable names with irrelevant emotional connotation. e.g.: marypoppins = (superman + starship) / god;".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found