diff options
author | 6543 <6543@obermui.de> | 2021-04-09 09:40:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-09 09:40:34 +0200 |
commit | 9c4601bdf8369ed72944085e3952111cf4aeea11 (patch) | |
tree | 2dcadaabed6dbe14ddba2d2513b736ff6b7f089f /modules | |
parent | 0991f9aa427ab923544c35d73232fa53c9db9120 (diff) | |
download | gitea-9c4601bdf8369ed72944085e3952111cf4aeea11.tar.gz gitea-9c4601bdf8369ed72944085e3952111cf4aeea11.zip |
Code Formats, Nits & Unused Func/Var deletions (#15286)
* _ to unused func options
* rm useless brakets
* rm trifial non used models functions
* rm dead code
* rm dead global vars
* fix routers/api/v1/repo/issue.go
* dont overload import module
Diffstat (limited to 'modules')
-rw-r--r-- | modules/markup/common/linkify.go | 4 | ||||
-rw-r--r-- | modules/process/manager.go | 7 | ||||
-rw-r--r-- | modules/queue/bytefifo.go | 4 | ||||
-rw-r--r-- | modules/queue/helper.go | 2 | ||||
-rw-r--r-- | modules/queue/queue_bytefifo.go | 4 | ||||
-rw-r--r-- | modules/queue/queue_disk.go | 2 | ||||
-rw-r--r-- | modules/queue/queue_redis.go | 2 | ||||
-rw-r--r-- | modules/queue/unique_queue_disk.go | 2 | ||||
-rw-r--r-- | modules/queue/unique_queue_redis.go | 2 | ||||
-rw-r--r-- | modules/references/references.go | 2 | ||||
-rw-r--r-- | modules/repofiles/action.go | 2 | ||||
-rw-r--r-- | modules/setting/setting.go | 5 | ||||
-rw-r--r-- | modules/storage/helper.go | 2 | ||||
-rw-r--r-- | modules/storage/storage.go | 2 |
14 files changed, 15 insertions, 27 deletions
diff --git a/modules/markup/common/linkify.go b/modules/markup/common/linkify.go index 25621bf801..8a4b2a8985 100644 --- a/modules/markup/common/linkify.go +++ b/modules/markup/common/linkify.go @@ -122,9 +122,7 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont } } } - if m == nil { - return nil - } + if consumes != 0 { s := segment.WithStop(segment.Start + 1) ast.MergeOrAppendTextSegment(parent, s) diff --git a/modules/process/manager.go b/modules/process/manager.go index 9d57f4eb7b..e42e38a0f0 100644 --- a/modules/process/manager.go +++ b/modules/process/manager.go @@ -8,7 +8,6 @@ package process import ( "bytes" "context" - "errors" "fmt" "io" "os/exec" @@ -22,10 +21,8 @@ import ( // then we delete the singleton. var ( - // ErrExecTimeout represent a timeout error - ErrExecTimeout = errors.New("Process execution timeout") - manager *Manager - managerInit sync.Once + manager *Manager + managerInit sync.Once // DefaultContext is the default context to run processing commands in DefaultContext = context.Background() diff --git a/modules/queue/bytefifo.go b/modules/queue/bytefifo.go index 2cd0ba0b95..94478e6f05 100644 --- a/modules/queue/bytefifo.go +++ b/modules/queue/bytefifo.go @@ -23,7 +23,7 @@ type UniqueByteFIFO interface { Has(data []byte) (bool, error) } -var _ (ByteFIFO) = &DummyByteFIFO{} +var _ ByteFIFO = &DummyByteFIFO{} // DummyByteFIFO represents a dummy fifo type DummyByteFIFO struct{} @@ -48,7 +48,7 @@ func (*DummyByteFIFO) Len() int64 { return 0 } -var _ (UniqueByteFIFO) = &DummyUniqueByteFIFO{} +var _ UniqueByteFIFO = &DummyUniqueByteFIFO{} // DummyUniqueByteFIFO represents a dummy unique fifo type DummyUniqueByteFIFO struct { diff --git a/modules/queue/helper.go b/modules/queue/helper.go index 161c2fe8e7..e0368bce3a 100644 --- a/modules/queue/helper.go +++ b/modules/queue/helper.go @@ -50,7 +50,7 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) { var err error configBytes, err = json.Marshal(cfg) - ok = (err == nil) + ok = err == nil } if !ok { // no ... we've tried hard enough at this point - throw an error! diff --git a/modules/queue/queue_bytefifo.go b/modules/queue/queue_bytefifo.go index fe5178ff2d..bc86078493 100644 --- a/modules/queue/queue_bytefifo.go +++ b/modules/queue/queue_bytefifo.go @@ -21,7 +21,7 @@ type ByteFIFOQueueConfiguration struct { Name string } -var _ (Queue) = &ByteFIFOQueue{} +var _ Queue = &ByteFIFOQueue{} // ByteFIFOQueue is a Queue formed from a ByteFIFO and WorkerPool type ByteFIFOQueue struct { @@ -196,7 +196,7 @@ func (q *ByteFIFOQueue) IsTerminated() <-chan struct{} { return q.terminated } -var _ (UniqueQueue) = &ByteFIFOUniqueQueue{} +var _ UniqueQueue = &ByteFIFOUniqueQueue{} // ByteFIFOUniqueQueue represents a UniqueQueue formed from a UniqueByteFifo type ByteFIFOUniqueQueue struct { diff --git a/modules/queue/queue_disk.go b/modules/queue/queue_disk.go index 88b8c414c0..6c15a8e63b 100644 --- a/modules/queue/queue_disk.go +++ b/modules/queue/queue_disk.go @@ -55,7 +55,7 @@ func NewLevelQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error) return queue, nil } -var _ (ByteFIFO) = &LevelQueueByteFIFO{} +var _ ByteFIFO = &LevelQueueByteFIFO{} // LevelQueueByteFIFO represents a ByteFIFO formed from a LevelQueue type LevelQueueByteFIFO struct { diff --git a/modules/queue/queue_redis.go b/modules/queue/queue_redis.go index 2b1d36f0ad..af2cc30335 100644 --- a/modules/queue/queue_redis.go +++ b/modules/queue/queue_redis.go @@ -69,7 +69,7 @@ type redisClient interface { Close() error } -var _ (ByteFIFO) = &RedisByteFIFO{} +var _ ByteFIFO = &RedisByteFIFO{} // RedisByteFIFO represents a ByteFIFO formed from a redisClient type RedisByteFIFO struct { diff --git a/modules/queue/unique_queue_disk.go b/modules/queue/unique_queue_disk.go index dd6ac1a538..8ec8848bc4 100644 --- a/modules/queue/unique_queue_disk.go +++ b/modules/queue/unique_queue_disk.go @@ -59,7 +59,7 @@ func NewLevelUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, return queue, nil } -var _ (UniqueByteFIFO) = &LevelUniqueQueueByteFIFO{} +var _ UniqueByteFIFO = &LevelUniqueQueueByteFIFO{} // LevelUniqueQueueByteFIFO represents a ByteFIFO formed from a LevelUniqueQueue type LevelUniqueQueueByteFIFO struct { diff --git a/modules/queue/unique_queue_redis.go b/modules/queue/unique_queue_redis.go index 96fcad1a83..20a50cc1f2 100644 --- a/modules/queue/unique_queue_redis.go +++ b/modules/queue/unique_queue_redis.go @@ -62,7 +62,7 @@ func NewRedisUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, return queue, nil } -var _ (UniqueByteFIFO) = &RedisUniqueByteFIFO{} +var _ UniqueByteFIFO = &RedisUniqueByteFIFO{} // RedisUniqueByteFIFO represents a UniqueByteFIFO formed from a redisClient type RedisUniqueByteFIFO struct { diff --git a/modules/references/references.go b/modules/references/references.go index c243f25f5d..6c0db0cf47 100644 --- a/modules/references/references.go +++ b/modules/references/references.go @@ -296,7 +296,7 @@ func convertFullHTMLReferencesToShortRefs(re *regexp.Regexp, contentBytes *[]byt // our new section has length endPos - match[3] // our old section has length match[9] - match[3] - (*contentBytes) = (*contentBytes)[:len((*contentBytes))-match[9]+endPos] + *contentBytes = (*contentBytes)[:len(*contentBytes)-match[9]+endPos] pos = endPos } } diff --git a/modules/repofiles/action.go b/modules/repofiles/action.go index 52cc89dbae..d7e3ff4525 100644 --- a/modules/repofiles/action.go +++ b/modules/repofiles/action.go @@ -201,7 +201,7 @@ func UpdateIssuesCommit(doer *models.User, repo *models.Repository, commits []*r continue } } - close := (ref.Action == references.XRefActionCloses) + close := ref.Action == references.XRefActionCloses if close && len(ref.TimeLog) > 0 { if err := issueAddTime(refIssue, doer, c.Timestamp, ref.TimeLog); err != nil { return err diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 280987ed66..f609edba17 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -318,7 +318,6 @@ var ( LogRootPath string DisableRouterLog bool RouterLogLevel log.Level - RouterLogMode string EnableAccessLog bool AccessLogTemplate string EnableXORMLog bool @@ -408,10 +407,6 @@ var ( IsWindows bool HasRobotsTxt bool InternalToken string // internal access token - - // UILocation is the location on the UI, so that we can display the time on UI. - // Currently only show the default time.Local, it could be added to app.ini after UI is ready - UILocation = time.Local ) // IsProd if it's a production mode diff --git a/modules/storage/helper.go b/modules/storage/helper.go index 46ab82aed6..4d8ba8e6d9 100644 --- a/modules/storage/helper.go +++ b/modules/storage/helper.go @@ -50,7 +50,7 @@ func toConfig(exemplar, cfg interface{}) (interface{}, error) { var err error configBytes, err = json.Marshal(cfg) - ok = (err == nil) + ok = err == nil } if !ok { // no ... we've tried hard enough at this point - throw an error! diff --git a/modules/storage/storage.go b/modules/storage/storage.go index 65f8978e5a..984f154db4 100644 --- a/modules/storage/storage.go +++ b/modules/storage/storage.go @@ -19,8 +19,6 @@ import ( var ( // ErrURLNotSupported represents url is not supported ErrURLNotSupported = errors.New("url method not supported") - // ErrIterateObjectsNotSupported represents IterateObjects not supported - ErrIterateObjectsNotSupported = errors.New("iterateObjects method not supported") ) // ErrInvalidConfiguration is called when there is invalid configuration for a storage |