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

Report & generate missing type constraint in variable block #1476

Open
3 tasks
radeksimko opened this issue Oct 24, 2023 · 0 comments
Open
3 tasks

Report & generate missing type constraint in variable block #1476

radeksimko opened this issue Oct 24, 2023 · 0 comments

Comments

@radeksimko
Copy link
Member

radeksimko commented Oct 24, 2023

Context

Users may - and anecdotally often do - write configuration without considering the type of variables, for example:

variable "foo" {
}

Sometimes they go one step further but still not very far by defining the type as any:

variable "foo" {
  type = any
}

or they may let the type to be inferred from the default value, e.g.

variable "foo" {
  default = []
}

In all these cases, they can introduce bugs due to type mismatches/conversions or at least make it much more difficult for collaborators and consumers of the module to understand the module as a whole.

Proposal

  • Raise missing type constraint as a warning diagnostic, suggesting that types are better declared explicitly to communicate intentions
  • Raise type = any as informal diagnostic, suggesting more concrete type, to communicate intentions
  • Provide quickfix code action to generate type based on default value
@radeksimko radeksimko changed the title Raise missing type constraint in variable block as a diagnostic Report & generate missing type constraint in variable block Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant