Identypo เป็นเครื่องมือวิเคราะห์แบบคงที่เพื่อค้นหาความผิดพลาดในตัวระบุ (ฟังก์ชั่นการเรียกใช้ฟังก์ชันตัวแปรค่าคงที่การประกาศประเภทแพ็คเกจฉลาก) รวมถึงฟังก์ชั่นอูฐตัวแปร ฯลฯ มันถูกสร้างขึ้นบนแพ็คเกจ Misspell ของลูกค้า 9
go get -u github.com/alexkohler/identypo/cmd/identypo
misspell ดำเนินการกับข้อความดิบและความคิดเห็น identypo ทำงานบนตัวระบุ AST (เช่นชื่อตัวแปรชื่อฟังก์ชั่น ฯลฯ ) ยิ่งไปกว่านั้น identypo แยกตัวระบุอูฐแต่ละตัวหากจำเป็น (MyIdentifierName กลายเป็น 'ชื่อตัวระบุของฉัน') ก่อนที่จะวิเคราะห์ว่ามีการสะกดอย่างถูกต้องหรือไม่ ภายใต้ประทุน identypo กำลังใช้เอ็นจิ้นการสะกดคำของ ACSPELL เพื่อตรวจสอบว่าคำที่ไม่ถูกสะกดถูกสะกดไม่ถูกต้องหรือไม่
เช่นเดียวกับเครื่องมือการวิเคราะห์แบบคงที่ GO อื่น ๆ (เช่น Golint, Go Vet), Identypo สามารถเรียกใช้กับชื่อไฟล์หนึ่งชื่อไดเรกทอรีหรือแพ็คเกจหนึ่งหรือมากกว่าหนึ่งรายการ Identypo ยังรองรับ ... Wildcard โดยค่าเริ่มต้นมันจะค้นหาการพิมพ์ผิดในตัวระบุทุกตัว (ฟังก์ชั่นการเรียกใช้ฟังก์ชันตัวแปรค่าคงที่การประกาศประเภทแพ็คเกจป้ายกำกับ)
identypo [flags] files/directories/packages
-i="nto,creater" ) นี่คือการผ่านโดยตรงไปยังแพ็คเกจ MISSPELLหมายเหตุ: โดยค่าเริ่มต้น identypo จะตรวจสอบการพิมพ์ผิดในทุกตัวระบุ (ฟังก์ชั่น, การเรียกใช้ฟังก์ชัน, ตัวแปร, ค่าคงที่, การประกาศประเภท, แพ็คเกจ, ฉลาก) ในกรณีนี้ไม่จำเป็นต้องระบุธง เนื่องจากขาดความถี่ในปัจจุบันจึงไม่มีธงที่จะค้นหาการประกาศประเภทแพ็คเกจหรือฉลากเท่านั้น
ตัวอย่างบางส่วนจากไลบรารีมาตรฐาน GO (ใช้ธง -i เพื่อระงับบางส่วนที่ไม่ใช่ออก):
$ identypo -i= " rela,nto,onot,alltime " ./...
cmd/trace/goroutines.go:169 " dividened " should be dividend in dividened
cmd/trace/goroutines.go:173 " dividened " should be dividend in dividened
cmd/trace/goroutines.go:175 " dividened " should be dividend in dividened
cmd/trace/goroutines.go:179 " dividened " should be dividend in dividened
cmd/trace/annotations.go:1162 " dividened " should be dividend in dividened
cmd/trace/annotations.go:1166 " dividened " should be dividend in dividened
cmd/trace/annotations.go:1168 " dividened " should be dividend in dividened
cmd/trace/annotations.go:1172 " dividened " should be dividend in dividened
crypto/x509/verify.go:208 " Comparisions " should be Comparisons in MaxConstraintComparisions
crypto/x509/verify.go:585 " Comparisions " should be Comparisons in MaxConstraintComparisions // cmd/trace/annotations.go:1162 dividened" should be dividend in dividened
"percent" : func ( dividened , divisor int64 ) template. HTML {
// crypto/x509/verify.go:208 "Comparisions" should be Comparisons in MaxConstraintComparisions
type VerifyOptions struct {
...
MaxConstraintComparisions int
}ตัวอย่างที่เลือกจาก Kubernetes:
$ identypo ./...
cmd/kubeadm/app/util/apiclient/wait.go:51 " inital " should be initial in initalTimeout
pkg/apis/certificates/types.go:125 " Committment " should be Commitment in UsageContentCommittment
test/e2e_node/eviction_test.go:51 " Dissapear " should be Disappear in pressureDissapearTimeout
pkg/scheduler/scheduler_test.go:705 " Satsified " should be Satisfied in FindUnboundSatsified
pkg/kubectl/cmd/scale.go:265 " Psuedo " should be Pseudo in JobPsuedoScaler // cmd/kubeadm/app/util/apiclient/wait.go:51 "inital" should be initial in initalTimeout
WaitForHealthyKubelet ( initalTimeout time . Duration , healthzEndpoint string ) error
// pkg/apis/certificates/types.go:125 "Committment" should be Commitment in UsageContentCommittment
UsageContentCommittment KeyUsage = "content commitment"
// test/e2e_node/eviction_test.go:51 "Dissapear" should be Disappear in pressureDissapearTimeout
const (
...
pressureDissapearTimeout = 1 * time . Minute
...
)
// pkg/scheduler/scheduler_test.go:705 "Satsified" should be Satisfied in FindUnboundSatsified
volumeBinderConfig: & persistentvolume. FakeVolumeBinderConfig {
...
FindUnboundSatsified : true ,
...
}
// pkg/kubectl/cmd/scale.go:265 "Psuedo" should be Pseudo in JobPsuedoScaler
scaler := scalejob. JobPsuedoScaler {
JobsClient : jobsClient ,
}โปรดเปิดปัญหาและ/หรือ PR สำหรับคุณสมบัติ/ข้อบกพร่องใด ๆ
หากคุณมีความสุขกับ identypo ลองดูเครื่องมือ anaylsis แบบคงที่อื่น ๆ ของฉัน!