Skip to content

Autoformat setting for all lower case or all upper case keywords #547

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

Closed
wsmelton opened this issue Mar 15, 2017 · 16 comments
Closed

Autoformat setting for all lower case or all upper case keywords #547

wsmelton opened this issue Mar 15, 2017 · 16 comments
Labels
Issue-Enhancement A feature request (enhancement).

Comments

@wsmelton
Copy link

wsmelton commented Mar 15, 2017

Feature Request

Loving the new format settings for 0.10.0 release. Would it be possible to add control over case of keywords?

Examples

I add to my settings something like:

"powershell.codeFormatting.allLowercaseKeywords": true,

That setting would turn this:

Begin {
    Write-Verbose "I'm starting now"
}
PROCESS {
    IF ($notify -eq $true) {
        Write-Verbose "Do something"
    }
    Else {
        write-verbose "Do something"
    }
}
end {
    Write-Verbose "Do something else"
}

into this:

begin {
    Write-Verbose "I'm starting now"
}
process {
    if ($notify -eq $true) {
        Write-Verbose "Do something"
    }
    else {
        Write-Verbose "Do something"
    }
}
end {
    Write-Verbose "Do something else"
}
@bgelens
Copy link

bgelens commented Mar 15, 2017

I'm with you with this one :) I hate it when keywords scream at me

@wsmelton
Copy link
Author

It would be nice if we could even add it for operators as well...annoys me to no end to see if ($var -EQ 1).

@daviwil
Copy link
Contributor

daviwil commented Mar 15, 2017

Good idea!

@daviwil daviwil added this to the 0.11.0 milestone Mar 15, 2017
@daviwil daviwil added the Issue-Enhancement A feature request (enhancement). label Mar 15, 2017
@daviwil daviwil modified the milestones: 0.11.0, 0.12.0 Mar 22, 2017
@daviwil daviwil modified the milestones: 0.12.0, Next Feature Update Apr 4, 2017
@daviwil daviwil modified the milestones: April 2017, May 2017 May 8, 2017
@daviwil daviwil modified the milestones: May 2017, June 2017 Jun 1, 2017
@ChrisWarwick
Copy link

Please (please!) add Pascal case as an option for keywords too (Foreach, If, etc etc). I realise I'm not in the majority here but it's a style I've used forever and I guess it would be easy to add to the above enhancement (and I'm sure there are other weirdos out there who would like this... :-))

Thanks!

@daviwil daviwil modified the milestones: June 2017, July 2017 Jul 11, 2017
@daviwil daviwil modified the milestones: July 2017, Future Oct 26, 2017
@Halkcyon
Copy link

Halkcyon commented May 11, 2018

@ChrisWarwick I would vote for a true PascalCase (ForEach, ElseIf, etc.). I think that should be the three settings (PascalCase, lowercase, UPPERCASE). I was pretty disappointed to run across this today while exploring automatic code formatting and keywords are forgotten.

@wsmelton I had no idea people did anything but lowercase operators.. Looks like such a bad design decision on script-writers' parts.

@TylerLeonhardt
Copy link
Member

@bergmeister is this something we could handle in PSSA?

@bergmeister
Copy link
Contributor

bergmeister commented May 14, 2018

@tylerl0706 Yes, but it would be a style rule, not a code analysis rule. There is already a similar issue in PSSA that falls into this category: PowerShell/PSScriptAnalyzer#767
It is up for grabs since this is more of a 'nice to have' feature, I myself can just about manage to control my developer's OCD 🤣
P.S. It seems the VSCode repo has another similar issue to this one as well: #960

@TylerLeonhardt
Copy link
Member

Thanks, @bergmeister! That's what I thought. I'm going to close this issue in favor of the one in PSSA since this would be addressed there :)

@wsmelton
Copy link
Author

So will PSSA implement the ability to apply the rule when we format a file?

@bergmeister
Copy link
Contributor

@wsmelton The issue is marked as up for grabs, so anyone can feel free to do it. From my side, I think there are bigger fishes to fry, so from my side it is not a priority. I am only the community maintainer of it and I cannot speak for the MSFT side.

@TylerLeonhardt
Copy link
Member

TylerLeonhardt commented May 14, 2018

@wsmelton if your question is can PSSA do this, the answer is yes. If it's will the feature be added, refer to @bergmeister's answer ^

@bergmeister
Copy link
Contributor

bergmeister commented May 14, 2018

@tylerl0706 Can you give an answer from the MSFT side whether you guys are interested in that? I already do a lot of community stuff for PSSA but it is just a matter of prioritization since there are more than enough issues to do and some of them are badly affecting users and the reality is simply that there is only a finite number of hours in a day. I am happy to help though if someone wants to tackle it.
This is what OpenSource means, feature requests are considered but it is not 'feature-as-a-service'

@TylerLeonhardt
Copy link
Member

I'm not really spending a lot of time in PSSA - that's more on @JamesWTruher and @kalgiz (when she gets back from vacation).

Generally speaking, if there are a lot of thumbs up (👍), we'll likely prioritize it higher.

This might go without saying... if you want something really badly, and we don't have the engineering power to do it, pull requests are always welcome 😄 and we have smart folks like @bergmeister and the other two mentioned to help guide folks through the process!

@wsmelton
Copy link
Author

I'm more concerned with implementation of it. If I open a 350 line script that someone used say PowerShell Studio to develop it. PS Studio can default to doing something like ForEach which is not my preference. If the feature is implemented using PSSA that means all it will do is flag the ForEach as a problem...which I don't use PSSA other than in VS Code and I don't recall any shortcut for "go fix all". On the other side if this is implemented in VS Code + PS Extension, I have the ability to format document and it all is taken care of...

@rkeithhill
Copy link
Contributor

@wsmelton The PowerShell extension uses PSSA for all its automatic formatting. So the feature/fix needs to be added to PSSA first, then the PowerShell extension for VSCode will pick it up via a PSSA update.

@bergmeister
Copy link
Contributor

I should add that PSSA is consumed indirectly by PowerShellEditorServices, therefore any Editor has theoretically the capability to make use of it. Apart from that the cmdlets by PSSA can be used manually to auto-format one or multiple scripts in one go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

9 participants