Skip to content

Commit

Permalink
Added more linting module
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferdinand Neman committed Aug 16, 2023
1 parent 87ef701 commit 924c709
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
20 changes: 10 additions & 10 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ linters:
# - contextcheck
# - cyclop
- deadcode
# - decorder
- decorder
# - depguard
# - dogsled
- dogsled
# - dupl
# - dupword
# - durationcheck
- durationcheck
# - errcheck
# - errchkjson
# - errname
Expand All @@ -53,11 +53,11 @@ linters:
# - godot
# - godox
# - goerr113
# - gofmt
- gofmt
# - gofumpt
# - goheader
# - goimports
# - golint
- golint
# - gomnd
# - gomoddirectives
# - gomodguard
Expand Down Expand Up @@ -136,12 +136,12 @@ linters:
# - contextcheck
- cyclop
# - deadcode
- decorder
# - decorder
- depguard
- dogsled
# - dogsled
- dupl
- dupword
- durationcheck
# - durationcheck
- errcheck
- errchkjson
- errname
Expand All @@ -166,11 +166,11 @@ linters:
- godot
- godox
- goerr113
- gofmt
# - gofmt
- gofumpt
- goheader
- goimports
- golint
# - golint
- gomnd
- gomoddirectives
- gomodguard
Expand Down
2 changes: 1 addition & 1 deletion ast/DataContext.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type DataContext struct {
func (ctx *DataContext) GetKeys() []string {
ret := make([]string, len(ctx.ObjectStore))
c := 0
for k, _ := range ctx.ObjectStore {
for k := range ctx.ObjectStore {
ret[c] = k
c++
}
Expand Down
2 changes: 1 addition & 1 deletion editor/StaticRoute.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func GetFile(path string) (*FileData, error) {
if err != nil {
return nil, err
}
mimeType, err := mime.MimeForFileName(path)
mimeType, err := mime.GetMimeForFileName(path)
if err != nil {

return &FileData{
Expand Down
25 changes: 14 additions & 11 deletions editor/mime/Mime.go
Original file line number Diff line number Diff line change
Expand Up @@ -721,27 +721,28 @@ var (
}
)

// MimeForFileName utility mimetype lokup
func MimeForFileName(filename string) (string, error) {
// GetMimeForFileName utility mimetype lokup
func GetMimeForFileName(filename string) (string, error) {
reg := regexp.MustCompile(`[a-zA-Z0-9]+$`)
if reg.MatchString(filename) {
ext := reg.FindString(filename)

return MimeForExtension(ext)
} else {
return "", fmt.Errorf("can not find extension of file : %s", filename)
return GetMimeForExtension(ext)
}

return "", fmt.Errorf("can not find extension of file : %s", filename)
}

// IsPrintableChar checks if a type is printable
func IsPrintableChar(char byte) bool {
if char&0x80 == 0x80 {
return false
} else if char >= 0x20 || char == 0x09 || char == 0x0A || char == 0x0D || char == 239 {

return true
} else {
return false
}

return false
}

// IsAllPrintableChar checks for the printable chars
Expand All @@ -756,12 +757,14 @@ func IsAllPrintableChar(bytes []byte) bool {
return float64(nonprintable)/float64(len(bytes)) < 0.03
}

// MimeForExtension lookup short code to string extensions
func MimeForExtension(extension string) (string, error) {
// GetMimeForExtension lookup short code to string extensions
func GetMimeForExtension(extension string) (string, error) {
ex := strings.ToLower(extension)
if typ, ok := mimeMap[ex]; ok {

return typ, nil
} else {
return "", fmt.Errorf("no mime type for extension : %s", extension)
}

return "", fmt.Errorf("no mime type for extension : %s", extension)

}

0 comments on commit 924c709

Please sign in to comment.