PowerShell / PowerShell/PSScriptAnalyzer

Formatting Issue, example included

Đang mở
#1,647 10 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Area - Formatter Issue - Bug
Ngôn ngữ chính
C#
Star
2.2k
Fork
414
Merge trung bình
13 giờ 1 phút
Pull request đã merge (30 ngày)
2

Mô tả

Issue Type: Bug

This is an example of the formatting issue I have been struggling with. It appears that that using a multi-line piping statement, along with the 'Out-Null' is the cause in this situation. Formatting the document adds an additional tab each time this code happens. I have much more involved code then this example that becomes really confusing when this indent issue occurs.

function Test-Format([int]$num) {
	if($num -eq 1){
		Get-ChildItem -Path 'c:\*.*' | Where-Object {$_.name -like 'test1.*'} |
			ForEach-Object{Remove-Item -Path $_ | Out-Null}
		}
		else{
			Get-ChildItem -Path 'c:\*.*' | Where-Object {$_.name -like 'test2.*'} |
				ForEach-Object{Remove-Item -Path $_ | Out-Null}
			}
		}
		Test-format -num 1

Extension version: 2021.2.2
VS Code version: Code 1.54.1 (f30a9b73e8ffc278e71575118b6bf568f04587c8, 2021-03-04T22:38:31.419Z)
OS version: Windows_NT x64 10.0.19042

System Info
Item Value
CPUs Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz (8 x 3700)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
protected_video_decode: unavailable_off
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 31.92GB (22.25GB free)
Process Argv --crash-reporter-id 73837bc4-9684-4f62-8d48-bb5a4bc03bd8
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244cf:30256637
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
dockersubset:30265998
pythontbcf:30265426
vspre833:30267464

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện vấn đề với ví dụ pipeline PowerShell nhiều dòng và Out-Null trong báo cáo này, sử dụng các phiên bản đã nêu của extension PSScriptAnalyzer và VS Code nếu có thể. Truy tìm điểm vào của formatter xử lý việc thụt lề pipeline; công việc được xem là hoàn tất khi việc format lặp lại không còn thêm các tab thừa và cấu trúc if/else được hiển thị vẫn được căn chỉnh chính xác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
powershell
Lĩnh vực
tooling
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.