Skip to content

Commit 4942a62

Browse files
committed
Fix go-lint warnings
1 parent 22cdcd4 commit 4942a62

File tree

7 files changed

+21
-4
lines changed

7 files changed

+21
-4
lines changed

inotify-proxy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"strings"
1111
)
1212

13+
// Version defines the version of the application. This variable will be overridden by build system
1314
var Version = "dev"
1415

1516
func main() {

internal/config/config.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ import (
66
"io/ioutil"
77
)
88

9+
// Config is the root struct for the application configuration
910
type Config struct {
1011
Entries []WatchEntry `yaml:"watch"`
1112

1213
OldGlobalProfile *string `yaml:"profile"`
1314
}
1415

16+
// WatchEntry is the configuration of one watch entry (directory) which is handled in a separate go-routine
1517
type WatchEntry struct {
1618
Directory string `yaml:"directory"`
1719
Extensions []string `yaml:"extensions"`
1820
Profile *string `yaml:"profile"`
1921
}
2022

23+
// AddEntry allows to add a new directory watch
2124
func (c *Config) AddEntry(e WatchEntry) {
2225
c.Entries = append(c.Entries, e)
2326
}
2427

28+
// GetEntryByDirectory returns the watch configuration of a given directory
2529
func (c *Config) GetEntryByDirectory(dir string) WatchEntry {
2630
for _, e := range c.Entries {
2731
if e.Directory == dir {
@@ -32,6 +36,7 @@ func (c *Config) GetEntryByDirectory(dir string) WatchEntry {
3236
return WatchEntry{}
3337
}
3438

39+
// Read a configuration from a file or other resource
3540
func Read(f io.Reader) (Config, error) {
3641
var (
3742
c Config
@@ -49,6 +54,7 @@ func Read(f io.Reader) (Config, error) {
4954
return c, err
5055
}
5156

57+
// Parse the config data and return a Config object
5258
func Parse(yamlData []byte) (Config, error) {
5359
var c Config
5460
err := yaml.Unmarshal(yamlData, &c)

internal/profile/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,41 @@
11
package profile
22

3+
// Profile is the base type of any profile
34
type Profile struct {
45
Extensions []string
56
}
67

8+
// Default is the default profile which allows all extensions
79
var Default = Profile{
810
Extensions: []string{"*"},
911
}
1012

13+
// LESS allows only .less extension
1114
var LESS = Profile{
1215
Extensions: []string{".less"},
1316
}
1417

18+
// Magento2Theme allows only extensions of a Magento 2 Theme
1519
var Magento2Theme = Profile{
1620
Extensions: []string{".css", ".js", ".less", ".sass", ".ts"},
1721
}
1822

23+
// Magento2Theme allows only extensions required for development of a Magento 2 Module / Extension
1924
var Magento2 = Profile{
2025
Extensions: []string{".css", ".html", ".less", ".sass", ".js", ".php", ".phtml", ".ts", ".xml"},
2126
}
2227

28+
// SASS allow only extensions related to the SASS tool
2329
var SASS = Profile{
2430
Extensions: []string{".sass", ".scss"},
2531
}
2632

33+
// VueStorefront allow only extensions related to vue-storefront projects
2734
var VueStorefront = Profile{
2835
Extensions: []string{".css", ".js", ".sass", ".ts"},
2936
}
3037

38+
// VueStorefront allow only .js (Javascript) and .ts (Typescript) extension
3139
var Javascript = Profile{
3240
Extensions: []string{".js", ".ts"},
3341
}

internal/profile/validator/path.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import (
77
"strings"
88
)
99

10+
// IsPathValid checks if a path matches criteria to be included in watch process
1011
func IsPathValid(path string, entryConfig config.WatchEntry) bool {
1112

1213
if !isAllowedDirectory(path) {
1314
return false
1415
}
1516

1617
if len(entryConfig.Extensions) > 0 && !isAllowedFileExtension(path, entryConfig.Extensions) {
17-
return false
18+
return false
1819
}
1920

2021
if entryConfig.Profile == nil {

internal/util/file.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package util
22

33
import "os"
44

5+
// FileExists checks if a file or directory exists in the filesystem
56
func FileExists(path string) bool {
67
info, err := os.Stat(path)
78

internal/watcher/types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package watcher
22

3+
// NodeInfo contains the required information for a file to watch
34
type NodeInfo struct {
45
modificationUnixTime int64
56
}
67

78
var fileMap = make(map[string]NodeInfo)
8-
9-
var selectedProfile = ""

internal/watcher/watcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
var mu sync.Mutex
1515
var wg sync.WaitGroup
1616

17+
// Watch starts the watch process of a defined directories of the given configuration
1718
func Watch(c config.Config, watchFrequenceSeconds int) {
1819
i := 0
1920

@@ -112,7 +113,7 @@ func isFileChanged(path string) bool {
112113
func garbageCollection() {
113114
mu.Lock()
114115
defer mu.Unlock()
115-
for path, _ := range fileMap {
116+
for path := range fileMap {
116117
if !util.FileExists(path) {
117118
delete(fileMap, path)
118119
color.Style{color.FgGray}.Printf("Deleted: %s\n", path)

0 commit comments

Comments
 (0)