Skip to content

Commit 58540a4

Browse files
committed
chore(lint): updated linters, relinted code
Signed-off-by: Frédéric BIDON <fredbi@yahoo.com>
1 parent 4686a2d commit 58540a4

File tree

2 files changed

+51
-49
lines changed

2 files changed

+51
-49
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ linters:
2121
- musttag
2222
- nestif
2323
- nlreturn
24+
- noinlineerr
2425
- nonamedreturns
2526
- paralleltest
2627
- testpackage
@@ -31,6 +32,7 @@ linters:
3132
- whitespace
3233
- wrapcheck
3334
- wsl
35+
- wsl_v5
3436
settings:
3537
dupl:
3638
threshold: 200

inflect.go

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,6 @@ func (rs *Ruleset) AddUncountable(word string) {
307307
rs.uncountables[strings.ToLower(word)] = true
308308
}
309309

310-
func (rs *Ruleset) isUncountable(word string) bool {
311-
// handle multiple words by using the last one
312-
words := strings.Split(word, " ")
313-
if _, exists := rs.uncountables[strings.ToLower(words[len(words)-1])]; exists {
314-
return true
315-
}
316-
return false
317-
}
318-
319310
// returns the plural form of a singular word
320311
func (rs *Ruleset) Pluralize(word string) string {
321312
if len(word) == 0 {
@@ -383,20 +374,6 @@ func (rs *Ruleset) Titleize(word string) string {
383374
return strings.Join(words, " ")
384375
}
385376

386-
func (rs *Ruleset) safeCaseAcronyms(word string) string {
387-
// convert an acroymn like HTML into Html
388-
for _, rule := range rs.acronyms {
389-
word = strings.ReplaceAll(word, rule.suffix, rule.replacement)
390-
}
391-
return word
392-
}
393-
394-
func (rs *Ruleset) seperatedWords(word, sep string) string {
395-
word = rs.safeCaseAcronyms(word)
396-
words := splitAtCaseChange(word)
397-
return strings.Join(words, sep)
398-
}
399-
400377
// lowercase underscore version "BigBen" -> "big_ben"
401378
func (rs *Ruleset) Underscore(word string) string {
402379
return rs.seperatedWords(word, "_")
@@ -452,32 +429,6 @@ func (rs *Ruleset) ParameterizeJoin(word, sep string) string {
452429
return word
453430
}
454431

455-
var lookalikes = map[string]*regexp.Regexp{
456-
"A": regexp.MustCompile(`À|Á|Â|Ã|Ä|Å`),
457-
"AE": regexp.MustCompile(`Æ`),
458-
"C": regexp.MustCompile(`Ç`),
459-
"E": regexp.MustCompile(`È|É|Ê|Ë`),
460-
"G": regexp.MustCompile(`Ğ`),
461-
"I": regexp.MustCompile(`Ì|Í|Î|Ï|İ`),
462-
"N": regexp.MustCompile(`Ñ`),
463-
"O": regexp.MustCompile(`Ò|Ó|Ô|Õ|Ö|Ø`),
464-
"S": regexp.MustCompile(`Ş`),
465-
"U": regexp.MustCompile(`Ù|Ú|Û|Ü`),
466-
"Y": regexp.MustCompile(`Ý`),
467-
"ss": regexp.MustCompile(`ß`),
468-
"a": regexp.MustCompile(`à|á|â|ã|ä|å`),
469-
"ae": regexp.MustCompile(`æ`),
470-
"c": regexp.MustCompile(`ç`),
471-
"e": regexp.MustCompile(`è|é|ê|ë`),
472-
"g": regexp.MustCompile(`ğ`),
473-
"i": regexp.MustCompile(`ì|í|î|ï|ı`),
474-
"n": regexp.MustCompile(`ñ`),
475-
"o": regexp.MustCompile(`ò|ó|ô|õ|ö|ø`),
476-
"s": regexp.MustCompile(`ş`),
477-
"u": regexp.MustCompile(`ù|ú|û|ü|ũ|ū|ŭ|ů|ű|ų`),
478-
"y": regexp.MustCompile(`ý|ÿ`),
479-
}
480-
481432
// transforms latin characters like é -> e
482433
func (rs *Ruleset) Asciify(word string) string {
483434
for repl, regex := range lookalikes {
@@ -523,6 +474,55 @@ func (rs *Ruleset) Ordinalize(str string) string {
523474
return fmt.Sprintf("%dth", number)
524475
}
525476

477+
func (rs *Ruleset) isUncountable(word string) bool {
478+
// handle multiple words by using the last one
479+
words := strings.Split(word, " ")
480+
if _, exists := rs.uncountables[strings.ToLower(words[len(words)-1])]; exists {
481+
return true
482+
}
483+
return false
484+
}
485+
486+
func (rs *Ruleset) safeCaseAcronyms(word string) string {
487+
// convert an acroymn like HTML into Html
488+
for _, rule := range rs.acronyms {
489+
word = strings.ReplaceAll(word, rule.suffix, rule.replacement)
490+
}
491+
return word
492+
}
493+
494+
func (rs *Ruleset) seperatedWords(word, sep string) string {
495+
word = rs.safeCaseAcronyms(word)
496+
words := splitAtCaseChange(word)
497+
return strings.Join(words, sep)
498+
}
499+
500+
var lookalikes = map[string]*regexp.Regexp{
501+
"A": regexp.MustCompile(`À|Á|Â|Ã|Ä|Å`),
502+
"AE": regexp.MustCompile(`Æ`),
503+
"C": regexp.MustCompile(`Ç`),
504+
"E": regexp.MustCompile(`È|É|Ê|Ë`),
505+
"G": regexp.MustCompile(`Ğ`),
506+
"I": regexp.MustCompile(`Ì|Í|Î|Ï|İ`),
507+
"N": regexp.MustCompile(`Ñ`),
508+
"O": regexp.MustCompile(`Ò|Ó|Ô|Õ|Ö|Ø`),
509+
"S": regexp.MustCompile(`Ş`),
510+
"U": regexp.MustCompile(`Ù|Ú|Û|Ü`),
511+
"Y": regexp.MustCompile(`Ý`),
512+
"ss": regexp.MustCompile(`ß`),
513+
"a": regexp.MustCompile(`à|á|â|ã|ä|å`),
514+
"ae": regexp.MustCompile(`æ`),
515+
"c": regexp.MustCompile(`ç`),
516+
"e": regexp.MustCompile(`è|é|ê|ë`),
517+
"g": regexp.MustCompile(`ğ`),
518+
"i": regexp.MustCompile(`ì|í|î|ï|ı`),
519+
"n": regexp.MustCompile(`ñ`),
520+
"o": regexp.MustCompile(`ò|ó|ô|õ|ö|ø`),
521+
"s": regexp.MustCompile(`ş`),
522+
"u": regexp.MustCompile(`ù|ú|û|ü|ũ|ū|ŭ|ů|ű|ų`),
523+
"y": regexp.MustCompile(`ý|ÿ`),
524+
}
525+
526526
/////////////////////////////////////////
527527
// the default global ruleset
528528
//////////////////////////////////////////

0 commit comments

Comments
 (0)