Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Fix handling of empty or undefined metavariables #95

Merged
merged 1 commit into from
Oct 1, 2021

Conversation

lmt-swallow
Copy link
Member

Description

This PR fixes handling of empty or undefined metavariables.

Suppose if we have (1) the following pattern:

pattern: |
  resource "hoge" :[NAME] {
    b = 2
    :[...C]
  }

and (2) the following code to match (in HCL, for example):

  resource "hoge" "foo" {
    b = 2
  }

and (3) the following rewrite option:

rewrite: |
  resource "hoge" :[NAME] {
    b = 3
    :[...C]
  }

The current version of Shisho emits the rewritten code with an unnecessary newline, due to metavariable C, as follows:

resource "hoge" "foo" {
  b = 3
  
}

This PR changes this behaviour. In detail, now Shisho emits the following clean output:

resource "hoge" "foo" {
  b = 3
}

Checklist

  • I opened a draft PR or added the [WIP] to the title if my PR is not ready for review.
  • I have reviewed the code by myself.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • I have added tests enough to show how your code behaves and that your code works as expected.

Additional Notes

N/A

Signed-off-by: Takashi Yoneuchi <takashi.yoneuchi@shift-js.info>
@netlify
Copy link

netlify bot commented Oct 1, 2021

✔️ Deploy Preview for cranky-fermi-e6c846 canceled.

🔨 Explore the source changes: 4adf90d

🔍 Inspect the deploy log: https://app.netlify.com/sites/cranky-fermi-e6c846/deploys/61574f54810dcc1249572b17

@lmt-swallow lmt-swallow merged commit a6a6827 into main Oct 1, 2021
@lmt-swallow lmt-swallow deleted the bugfix/fix-handling-of-undefined-metavariables branch October 1, 2021 18:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant