From 0f64f600cd02026a513c3e8a6fc01fb42ab9a683 Mon Sep 17 00:00:00 2001
From: Angelo Capossele <angelocapossele@gmail.com>
Date: Thu, 30 Apr 2020 12:23:49 +0100
Subject: [PATCH] Linter warning fix of plugins (#393)

* :rotating_light: fix linter warnings

* :rotating_light: fix import order
---
 plugins/cli/cli.go             |  1 +
 plugins/config/plugin.go       |  6 +++---
 plugins/database/plugin.go     |  6 ++----
 plugins/logger/plugin.go       |  1 +
 plugins/messagelayer/plugin.go | 12 +++++-------
 plugins/metrics/events.go      |  2 ++
 plugins/profiling/plugin.go    |  3 +++
 plugins/remotelog/plugin.go    |  8 ++++----
 8 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/plugins/cli/cli.go b/plugins/cli/cli.go
index bd362093..740d23b1 100644
--- a/plugins/cli/cli.go
+++ b/plugins/cli/cli.go
@@ -14,6 +14,7 @@ import (
 var enabledPlugins []string
 var disabledPlugins []string
 
+// AddPluginStatus adds the status (enabled=1, disabled=0) of a given plugin.
 func AddPluginStatus(name string, status int) {
 	switch status {
 	case node.Enabled:
diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go
index f9353574..596ad2b5 100644
--- a/plugins/config/plugin.go
+++ b/plugins/config/plugin.go
@@ -5,9 +5,8 @@ import (
 	"github.com/iotaledger/hive.go/logger"
 	"github.com/iotaledger/hive.go/node"
 	"github.com/iotaledger/hive.go/parameter"
-	"github.com/spf13/viper"
-
 	flag "github.com/spf13/pflag"
+	"github.com/spf13/viper"
 )
 
 // PluginName is the name of the config plugin.
@@ -21,7 +20,7 @@ var (
 	configName    = flag.StringP("config", "c", "config", "Filename of the config file without the file extension")
 	configDirPath = flag.StringP("config-dir", "d", ".", "Path to the directory containing the config file")
 
-	// viper
+	// Node is viper
 	Node *viper.Viper
 
 	// logger
@@ -35,6 +34,7 @@ var (
 	}
 )
 
+// Init triggers the Init event.
 func Init() {
 	Plugin.Events.Init.Trigger(Plugin)
 }
diff --git a/plugins/database/plugin.go b/plugins/database/plugin.go
index 2227b4ff..6a006b7b 100644
--- a/plugins/database/plugin.go
+++ b/plugins/database/plugin.go
@@ -1,17 +1,15 @@
-// database is a plugin that manages the badger database (e.g. garbage collection).
+// Package database is a plugin that manages the badger database (e.g. garbage collection).
 package database
 
 import (
 	"time"
 
-	"github.com/iotaledger/hive.go/timeutil"
-
 	"github.com/iotaledger/goshimmer/packages/database"
 	"github.com/iotaledger/goshimmer/packages/shutdown"
-
 	"github.com/iotaledger/hive.go/daemon"
 	"github.com/iotaledger/hive.go/logger"
 	"github.com/iotaledger/hive.go/node"
+	"github.com/iotaledger/hive.go/timeutil"
 )
 
 // PluginName is the name of the database plugin.
diff --git a/plugins/logger/plugin.go b/plugins/logger/plugin.go
index 9381eef4..5ccfc62b 100644
--- a/plugins/logger/plugin.go
+++ b/plugins/logger/plugin.go
@@ -13,6 +13,7 @@ const PluginName = "Logger"
 // Plugin is the plugin instance of the logger plugin.
 var Plugin = node.NewPlugin(PluginName, node.Enabled)
 
+// Init triggers the Init event.
 func Init() {
 	Plugin.Events.Init.Trigger(Plugin)
 }
diff --git a/plugins/messagelayer/plugin.go b/plugins/messagelayer/plugin.go
index e2729184..3aaed4c3 100644
--- a/plugins/messagelayer/plugin.go
+++ b/plugins/messagelayer/plugin.go
@@ -1,13 +1,6 @@
 package messagelayer
 
 import (
-	"github.com/iotaledger/hive.go/autopeering/peer"
-
-	"github.com/iotaledger/hive.go/daemon"
-	"github.com/iotaledger/hive.go/events"
-	"github.com/iotaledger/hive.go/logger"
-	"github.com/iotaledger/hive.go/node"
-
 	"github.com/iotaledger/goshimmer/packages/binary/messagelayer/message"
 	"github.com/iotaledger/goshimmer/packages/binary/messagelayer/messagefactory"
 	"github.com/iotaledger/goshimmer/packages/binary/messagelayer/messageparser"
@@ -17,6 +10,11 @@ import (
 	"github.com/iotaledger/goshimmer/packages/database"
 	"github.com/iotaledger/goshimmer/packages/shutdown"
 	"github.com/iotaledger/goshimmer/plugins/autopeering/local"
+	"github.com/iotaledger/hive.go/autopeering/peer"
+	"github.com/iotaledger/hive.go/daemon"
+	"github.com/iotaledger/hive.go/events"
+	"github.com/iotaledger/hive.go/logger"
+	"github.com/iotaledger/hive.go/node"
 )
 
 const (
diff --git a/plugins/metrics/events.go b/plugins/metrics/events.go
index 7f7721bf..acdb127c 100644
--- a/plugins/metrics/events.go
+++ b/plugins/metrics/events.go
@@ -4,7 +4,9 @@ import (
 	"github.com/iotaledger/hive.go/events"
 )
 
+// Events defines the events of the plugin.
 var Events = pluginEvents{
+	// ReceivedMPSUpdated triggers upon reception of a MPS update.
 	ReceivedMPSUpdated: events.NewEvent(uint64EventCaller),
 }
 
diff --git a/plugins/profiling/plugin.go b/plugins/profiling/plugin.go
index 6e823650..0a4cb782 100644
--- a/plugins/profiling/plugin.go
+++ b/plugins/profiling/plugin.go
@@ -2,6 +2,7 @@ package profiling
 
 import (
 	"net/http"
+	// import required to profile
 	_ "net/http/pprof"
 
 	"github.com/iotaledger/goshimmer/plugins/config"
@@ -10,9 +11,11 @@ import (
 )
 
 var (
+	// Plugin is the profiling plugin.
 	Plugin = node.NewPlugin("Profiling", node.Enabled, configure, run)
 )
 
+// CfgProfilingBindAddress defines the config flag of the profiling binding address.
 const CfgProfilingBindAddress = "profiling.bindAddress"
 
 func init() {
diff --git a/plugins/remotelog/plugin.go b/plugins/remotelog/plugin.go
index f69fe1b9..32f6ad6b 100644
--- a/plugins/remotelog/plugin.go
+++ b/plugins/remotelog/plugin.go
@@ -1,4 +1,4 @@
-// remotelog is a plugin that enables log messages being sent via UDP to a central ELK stack for debugging.
+// Package remotelog is a plugin that enables log messages being sent via UDP to a central ELK stack for debugging.
 // It is disabled by default and when enabled, additionally, logger.disableEvents=false in config.json needs to be set.
 // The destination can be set via logger.remotelog.serverAddress.
 // All events according to logger.level in config.json are sent.
@@ -18,13 +18,11 @@ import (
 	"github.com/iotaledger/goshimmer/plugins/autopeering/local"
 	"github.com/iotaledger/goshimmer/plugins/banner"
 	"github.com/iotaledger/goshimmer/plugins/config"
-
 	"github.com/iotaledger/hive.go/daemon"
 	"github.com/iotaledger/hive.go/events"
 	"github.com/iotaledger/hive.go/logger"
 	"github.com/iotaledger/hive.go/node"
 	"github.com/iotaledger/hive.go/workerpool"
-
 	"gopkg.in/src-d/go-git.v4"
 )
 
@@ -32,7 +30,7 @@ type logMessage struct {
 	Version   string    `json:"version"`
 	GitHead   string    `json:"gitHead,omitempty"`
 	GitBranch string    `json:"gitBranch,omitempty"`
-	NodeId    string    `json:"nodeId"`
+	NodeID    string    `json:"nodeId"`
 	Level     string    `json:"level"`
 	Name      string    `json:"name"`
 	Msg       string    `json:"msg"`
@@ -40,7 +38,9 @@ type logMessage struct {
 }
 
 const (
+	// CfgServerAddress defines the config flag of the server address.
 	CfgServerAddress = "logger.remotelog.serverAddress"
+	// CfgDisableEvents defines the config flag for disabling logger events.
 	CfgDisableEvents = "logger.disableEvents"
 	// PluginName is the name of the remote log plugin.
 	PluginName = "RemoteLog"
-- 
GitLab