dupword

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 10 Imported by: 0

README

dupword

A linter that checks for duplicate words in the source code (usually miswritten)

example

  1. Repeated words appear on two adjacent lines commit
--- a/src/cmd/compile/internal/ssa/schedule.go
+++ b/src/cmd/compile/internal/ssa/schedule.go
@@ -179,7 +179,7 @@ func schedule(f *Func) {
 					// scored CarryChainTail (and prove w is not a tail).
 					score[w.ID] = ScoreFlags
 				}
-				// Verify v has not been scored. If v has not been visited, v may be the
+				// Verify v has not been scored. If v has not been visited, v may be
 				// the final (tail) operation in a carry chain. If v is not, v will be
 				// rescored above when v's carry-using op is scored. When scoring is done,
 				// only tail operations will retain the CarryChainTail score.
  1. Repeated words appearing on the same line commit
--- a/src/net/http/cookiejar/jar.go
+++ b/src/net/http/cookiejar/jar.go
@@ -465,7 +465,7 @@ func (j *Jar) domainAndType(host, domain string) (string, bool, error) {
 		// dot in the domain-attribute before processing the cookie.
 		//
 		// Most browsers don't do that for IP addresses, only curl
-		// version 7.54) and and IE (version 11) do not reject a
+		// version 7.54) and IE (version 11) do not reject a
 		//     Set-Cookie: a=1; domain=.127.0.0.1
 		// This leading dot is optional and serves only as hint for
 		// humans to indicate that a cookie with "domain=.bbc.co.uk"

Install

go install github.com/Abirdcfly/dupword/cmd/dupword@latest

Or install the main branch (including the last commit) with:

go install github.com/Abirdcfly/dupword/cmd/dupword@master

Usage

Run with default settings(include test file, only check keywords the,a and and):

dupword ./...

Skip detection test file(*_test.go):

dupword -test=false ./...

All options:

$ dupword --help
dupword: checks for duplicate words in the source code (usually miswritten)

Usage: dupword [-flag] [package]

This analyzer checks miswritten duplicate words in comments or package doc or string declaration

Flags:
  -V    print version and exit
  -all
        no effect (deprecated)
  -c int
        display offending line with this many lines of context (default -1)
  -cpuprofile string
        write CPU profile to this file
  -debug string
        debug flags, any subset of "fpstv"
  -fix
        apply all suggested fixes
  -flags
        print analyzer flags in JSON
  -json
        emit JSON output
  -memprofile string
        write memory profile to this file
  -source
        no effect (deprecated)
  -tags string
        no effect (deprecated)
  -test
        indicates whether test files should be analyzed, too (default true)
  -trace string
        write trace log to this file
  -v    no effect (deprecated)

TODO

[ ] make keyword optional [ ] add this linter to golangci-lint [ ] rewrite the detection logic to make it more efficient

License

MIT

Documentation

Overview

Package dupword defines an Analyzer that checks that duplicate words int the source code.

Index

Constants

View Source
const (
	Doc = `` /* 164-byte string literal not displayed */

	Message = "Duplicate words found"
)

Variables

This section is empty.

Functions

func CheckOneKey

func CheckOneKey(raw, key string) (new string, find bool)

func NewAnalyzer

func NewAnalyzer(useDefaultWord bool, keyWord ...string) (*analysis.Analyzer, error)

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL