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.

Support refactoring "Extract variable"

See original GitHub issue

In Intellij, for languages like Java, you have refactoring support. This might become very handy in the HCL plugin too to support Terraform refactorings.

The first refactoring I would like to see supported is to replace a constant value with a variable, given the constant value as a default value.

On top of that, the existence of a file variables.tf seems to be best practice although it is not necessarily needed. But if we follow best practices, the refactoring “Extract variable” should put the variable in the variables.tf file and create this file when it doesn’t exist yet.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
VladRassokhincommented, Mar 10, 2017

Here’s test version of plugin if you’d like to try new refactoring.

0reactions
mkuzmincommented, Dec 15, 2016

before:

resource "tls_private_key" "ssh" {
  algorithm = "RSA"
}

after:

variable "algorithm" {
  default = "RSA"
}
resource "tls_private_key" "ssh" {
  algorithm = "${var.algorithm}"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extract Variable - Refactoring.Guru
The main reason for extracting variables is to make a complex expression more understandable, by dividing it into its intermediate parts. These could...
Read more >
Extract/Introduce variable - IntelliJ IDEA - JetBrains
In the editor, select an expression or its part that you want to extract. · Press Ctrl+Alt+V or from the main menu, select...
Read more >
Refactoring source code in Visual Studio Code
Visual Studio Code supports refactoring operations (refactorings) such as Extract Method and Extract Variable to improve your code base from within your ...
Read more >
Extract Variable - Refactoring
Extract Variable. open in web edition · How do I access the web edition? refactorgram. return order.quantity * order.itemPrice - Math.max(0, order.quantity ...
Read more >
Extract variable - Help | IntelliJ IDEA - JetBrains
If you come across an expression that is hard to understand or it is duplicated in several places throughout you code, the Extract...
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