Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6ebbbd9

Browse files
committed
chore: linting
1 parentfba1c44 commit6ebbbd9

File tree

3 files changed

+90
-90
lines changed

3 files changed

+90
-90
lines changed

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on:ubuntu-latest
1616
env:
1717
GO_VERSION:stable
18-
GOLANGCI_LINT_VERSION:v2.0
18+
GOLANGCI_LINT_VERSION:v2.1
1919
CGO_ENABLED:0
2020

2121
steps:

‎replace.go‎

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -78,59 +78,6 @@ func (r *Replacer) Compile() {
7878
r.engine=NewStringReplacer(r.Replacements...)
7979
}
8080

81-
/*
82-
line1 and line2 are different
83-
extract words from each line1
84-
85-
replace word -> newword
86-
if word == new-word
87-
88-
continue
89-
90-
if new-word in list of replacements
91-
92-
continue
93-
94-
new word not original, and not in list of replacements some substring got mixed up. UNdo.
95-
*/
96-
func (r*Replacer)recheckLine(sstring,lineNumint,buf io.Writer,nextfunc(Diff)) {
97-
first:=0
98-
redacted:=RemoveNotWords(s)
99-
100-
idx:=wordRegexp.FindAllStringIndex(redacted,-1)
101-
for_,ab:=rangeidx {
102-
word:=s[ab[0]:ab[1]]
103-
newword:=r.engine.Replace(word)
104-
ifnewword==word {
105-
// no replacement done
106-
continue
107-
}
108-
109-
// ignore camelCase words
110-
// https://github.com/client9/misspell/issues/113
111-
ifCaseStyle(word)==CaseUnknown {
112-
continue
113-
}
114-
115-
ifStringEqualFold(r.corrected[strings.ToLower(word)],newword) {
116-
// word got corrected into something we know
117-
io.WriteString(buf,s[first:ab[0]])
118-
io.WriteString(buf,newword)
119-
first=ab[1]
120-
next(Diff{
121-
FullLine:s,
122-
Line:lineNum,
123-
Original:word,
124-
Corrected:newword,
125-
Column:ab[0],
126-
})
127-
continue
128-
}
129-
// Word got corrected into something unknown. Ignore it
130-
}
131-
io.WriteString(buf,s[first:])
132-
}
133-
13481
// ReplaceGo is a specialized routine for correcting Golang source files.
13582
// Currently only checks comments, not identifiers for spelling.
13683
func (r*Replacer)ReplaceGo(inputstring) (string, []Diff) {
@@ -236,3 +183,56 @@ func (r *Replacer) ReplaceReader(raw io.Reader, w io.Writer, next func(Diff)) er
236183
}
237184
returnnil
238185
}
186+
187+
/*
188+
line1 and line2 are different
189+
extract words from each line1
190+
191+
replace word -> newword
192+
if word == new-word
193+
194+
continue
195+
196+
if new-word in list of replacements
197+
198+
continue
199+
200+
new word not original, and not in list of replacements some substring got mixed up. UNdo.
201+
*/
202+
func (r*Replacer)recheckLine(sstring,lineNumint,buf io.Writer,nextfunc(Diff)) {
203+
first:=0
204+
redacted:=RemoveNotWords(s)
205+
206+
idx:=wordRegexp.FindAllStringIndex(redacted,-1)
207+
for_,ab:=rangeidx {
208+
word:=s[ab[0]:ab[1]]
209+
newword:=r.engine.Replace(word)
210+
ifnewword==word {
211+
// no replacement done
212+
continue
213+
}
214+
215+
// ignore camelCase words
216+
// https://github.com/client9/misspell/issues/113
217+
ifCaseStyle(word)==CaseUnknown {
218+
continue
219+
}
220+
221+
ifStringEqualFold(r.corrected[strings.ToLower(word)],newword) {
222+
// word got corrected into something we know
223+
io.WriteString(buf,s[first:ab[0]])
224+
io.WriteString(buf,newword)
225+
first=ab[1]
226+
next(Diff{
227+
FullLine:s,
228+
Line:lineNum,
229+
Original:word,
230+
Corrected:newword,
231+
Column:ab[0],
232+
})
233+
continue
234+
}
235+
// Word got corrected into something unknown. Ignore it
236+
}
237+
io.WriteString(buf,s[first:])
238+
}

‎stringreplacer.go‎

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -204,42 +204,6 @@ func makeGenericReplacer(oldnew []string) *genericReplacer {
204204
returnr
205205
}
206206

207-
func (r*genericReplacer)lookup(sstring,ignoreRootbool) (valstring,keylenint,foundbool) {
208-
// Iterate down the trie to the end, and grab the value and keylen with
209-
// the highest priority.
210-
bestPriority:=0
211-
node:=&r.root
212-
n:=0
213-
fornode!=nil {
214-
ifnode.priority>bestPriority&& (!ignoreRoot||node!=&r.root) {
215-
bestPriority=node.priority
216-
val=node.value
217-
keylen=n
218-
found=true
219-
}
220-
221-
ifs=="" {
222-
break
223-
}
224-
ifnode.table!=nil {
225-
index:=r.mapping[ByteToLower(s[0])]
226-
ifint(index)==r.tableSize {
227-
break
228-
}
229-
node=node.table[index]
230-
s=s[1:]
231-
n++
232-
}elseifnode.prefix!=""&&StringHasPrefixFold(s,node.prefix) {
233-
n+=len(node.prefix)
234-
s=s[len(node.prefix):]
235-
node=node.next
236-
}else {
237-
break
238-
}
239-
}
240-
return
241-
}
242-
243207
func (r*genericReplacer)Replace(sstring)string {
244208
buf:=make(appendSliceWriter,0,len(s))
245209
r.WriteString(&buf,s)
@@ -305,6 +269,42 @@ func (r *genericReplacer) WriteString(w io.Writer, s string) (n int, err error)
305269
return
306270
}
307271

272+
func (r*genericReplacer)lookup(sstring,ignoreRootbool) (valstring,keylenint,foundbool) {
273+
// Iterate down the trie to the end, and grab the value and keylen with
274+
// the highest priority.
275+
bestPriority:=0
276+
node:=&r.root
277+
n:=0
278+
fornode!=nil {
279+
ifnode.priority>bestPriority&& (!ignoreRoot||node!=&r.root) {
280+
bestPriority=node.priority
281+
val=node.value
282+
keylen=n
283+
found=true
284+
}
285+
286+
ifs=="" {
287+
break
288+
}
289+
ifnode.table!=nil {
290+
index:=r.mapping[ByteToLower(s[0])]
291+
ifint(index)==r.tableSize {
292+
break
293+
}
294+
node=node.table[index]
295+
s=s[1:]
296+
n++
297+
}elseifnode.prefix!=""&&StringHasPrefixFold(s,node.prefix) {
298+
n+=len(node.prefix)
299+
s=s[len(node.prefix):]
300+
node=node.next
301+
}else {
302+
break
303+
}
304+
}
305+
return
306+
}
307+
308308
typeappendSliceWriter []byte
309309

310310
// Write writes to the buffer to satisfy io.Writer.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp