Skip to content

Commit

Permalink
chore: Fix linter findings for revive:comment-spacings (part 1) (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
zak-pawel committed Sep 19, 2024
1 parent ee9c47c commit 43590ca
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 118 deletions.
2 changes: 1 addition & 1 deletion cmd/telegraf/telegraf.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (t *Telegraf) watchRemoteConfigs(ctx context.Context, signals chan os.Signa
return
case <-ticker.C:
for _, configURL := range remoteConfigs {
resp, err := http.Head(configURL) //nolint: gosec // user provided URL
resp, err := http.Head(configURL) //nolint:gosec // user provided URL
if err != nil {
log.Printf("W! Error fetching config URL, %s: %s\n", configURL, err)
continue
Expand Down
22 changes: 11 additions & 11 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ func TestPersisterProcessorRegistration(t *testing.T) {
}
}

/*** Mockup INPUT plugin for (new) parser testing to avoid cyclic dependencies ***/
// Mockup INPUT plugin for (new) parser testing to avoid cyclic dependencies
type MockupInputPluginParserNew struct {
Parser telegraf.Parser
ParserFunc telegraf.ParserFunc
Expand All @@ -1311,7 +1311,7 @@ func (m *MockupInputPluginParserNew) SetParserFunc(f telegraf.ParserFunc) {
m.ParserFunc = f
}

/*** Mockup INPUT plugin for testing to avoid cyclic dependencies ***/
// Mockup INPUT plugin for testing to avoid cyclic dependencies
type MockupInputPlugin struct {
Servers []string `toml:"servers"`
Methods []string `toml:"methods"`
Expand Down Expand Up @@ -1341,7 +1341,7 @@ func (m *MockupInputPlugin) SetParser(parser telegraf.Parser) {
m.parser = parser
}

/*** Mockup INPUT plugin with ParserFunc interface ***/
// Mockup INPUT plugin with ParserFunc interface
type MockupInputPluginParserFunc struct {
parserFunc telegraf.ParserFunc
}
Expand All @@ -1356,7 +1356,7 @@ func (m *MockupInputPluginParserFunc) SetParserFunc(pf telegraf.ParserFunc) {
m.parserFunc = pf
}

/*** Mockup INPUT plugin without ParserFunc interface ***/
// Mockup INPUT plugin without ParserFunc interface
type MockupInputPluginParserOnly struct {
parser telegraf.Parser
}
Expand All @@ -1371,7 +1371,7 @@ func (m *MockupInputPluginParserOnly) SetParser(p telegraf.Parser) {
m.parser = p
}

/*** Mockup PROCESSOR plugin for testing to avoid cyclic dependencies ***/
// Mockup PROCESSOR plugin for testing to avoid cyclic dependencies
type MockupProcessorPluginParser struct {
Parser telegraf.Parser
ParserFunc telegraf.ParserFunc
Expand All @@ -1398,7 +1398,7 @@ func (m *MockupProcessorPluginParser) SetParserFunc(f telegraf.ParserFunc) {
m.ParserFunc = f
}

/*** Mockup PROCESSOR plugin without parser ***/
// Mockup PROCESSOR plugin without parser
type MockupProcessorPlugin struct {
Option string `toml:"option"`
state []uint64
Expand Down Expand Up @@ -1433,7 +1433,7 @@ func (m *MockupProcessorPlugin) SetState(state interface{}) error {
return nil
}

/*** Mockup PROCESSOR plugin with parser ***/
// Mockup PROCESSOR plugin with parser
type MockupProcessorPluginParserOnly struct {
Parser telegraf.Parser
}
Expand All @@ -1456,7 +1456,7 @@ func (m *MockupProcessorPluginParserOnly) SetParser(parser telegraf.Parser) {
m.Parser = parser
}

/*** Mockup PROCESSOR plugin with parser-function ***/
// Mockup PROCESSOR plugin with parser-function
type MockupProcessorPluginParserFunc struct {
Parser telegraf.ParserFunc
}
Expand All @@ -1479,7 +1479,7 @@ func (m *MockupProcessorPluginParserFunc) SetParserFunc(pf telegraf.ParserFunc)
m.Parser = pf
}

/*** Mockup OUTPUT plugin for testing to avoid cyclic dependencies ***/
// Mockup OUTPUT plugin for testing to avoid cyclic dependencies
type MockupOutputPlugin struct {
URL string `toml:"url"`
Headers map[string]string `toml:"headers"`
Expand All @@ -1502,7 +1502,7 @@ func (m *MockupOutputPlugin) Write(_ []telegraf.Metric) error {
return nil
}

/*** Mockup OUTPUT plugin for serializer testing to avoid cyclic dependencies ***/
// Mockup OUTPUT plugin for serializer testing to avoid cyclic dependencies
type MockupOutputPluginSerializerOld struct {
Serializer serializers.Serializer
}
Expand Down Expand Up @@ -1543,7 +1543,7 @@ func (*MockupOutputPluginSerializerNew) Write(_ []telegraf.Metric) error {
return nil
}

/*** Mockup INPUT plugin with state for testing to avoid cyclic dependencies ***/
// Mockup INPUT plugin with state for testing to avoid cyclic dependencies
type MockupState struct {
Name string
Version uint64
Expand Down
2 changes: 1 addition & 1 deletion config/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ func TestSecretImplTestSuiteProtected(t *testing.T) {
suite.Run(t, &SecretImplTestSuite{protected: true})
}

/*** Mockup (input) plugin for testing to avoid cyclic dependencies ***/
// Mockup (input) plugin for testing to avoid cyclic dependencies
type MockupSecretPlugin struct {
Secret Secret `toml:"secret"`
Expected string `toml:"expected"`
Expand Down
2 changes: 1 addition & 1 deletion config/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func TestTOMLParsingIntegerSizes(t *testing.T) {
}
}

/*** Mockup (input) plugin for testing to avoid cyclic dependencies ***/
// Mockup (input) plugin for testing to avoid cyclic dependencies
type MockupTypesPlugin struct {
Durations []config.Duration `toml:"durations"`
Sizes []config.Size `toml:"sizes"`
Expand Down
2 changes: 1 addition & 1 deletion internal/content_coding.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/klauspost/pgzip"
)

const defaultMaxDecompressionSize int64 = 500 * 1024 * 1024 //500MB
const defaultMaxDecompressionSize int64 = 500 * 1024 * 1024 // 500MB

// DecodingOption provide methods to change the decoding from the standard
// configuration.
Expand Down
2 changes: 1 addition & 1 deletion internal/globpath/globpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestCompileAndMatch(t *testing.T) {
}

tests := []test{
//test super asterisk
// test super asterisk
{path: filepath.Join(testdataDir, "**"), matches: 7},
// test single asterisk
{path: filepath.Join(testdataDir, "*.log"), matches: 3},
Expand Down
8 changes: 4 additions & 4 deletions internal/rotate/file_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (w *FileWriter) rotateIfNeeded() error {
if (w.interval > 0 && time.Now().After(w.expireTime)) ||
(w.maxSizeInBytes > 0 && w.bytesWritten >= w.maxSizeInBytes) {
if err := w.rotate(); err != nil {
//Ignore rotation errors and keep the log open
// Ignore rotation errors and keep the log open
fmt.Printf("unable to rotate the file %q, %s", w.filename, err.Error())
}
return w.openCurrent()
Expand All @@ -160,7 +160,7 @@ func (w *FileWriter) rotate() (err error) {

func (w *FileWriter) purgeArchivesIfNeeded() (err error) {
if w.maxArchives == -1 {
//Skip archiving
// Skip archiving
return nil
}

Expand All @@ -169,9 +169,9 @@ func (w *FileWriter) purgeArchivesIfNeeded() (err error) {
return err
}

//if there are more archives than the configured maximum, then purge older files
// if there are more archives than the configured maximum, then purge older files
if len(matches) > w.maxArchives {
//sort files alphanumerically to delete older files first
// sort files alphanumerically to delete older files first
sort.Strings(matches)
for _, filename := range matches[:len(matches)-w.maxArchives] {
if err := os.Remove(filename); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/snmp/field.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (f *Field) Init(tr Translator) error {
if f.Conversion == "" {
f.Conversion = conversion
}
//TODO use textual convention conversion from the MIB
// TODO use textual convention conversion from the MIB
}

if f.SecondaryIndexTable && f.SecondaryIndexUse {
Expand Down
2 changes: 1 addition & 1 deletion internal/snmp/mib_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func LoadMibsFromPath(paths []string, log telegraf.Logger, loader MibLoader) err
log.Warnf("Couldn't evaluate symbolic links for %v: %v", symlink, err)
continue
}
//replace symlink's info with the target's info
// replace symlink's info with the target's info
info, err = os.Lstat(target)
if err != nil {
log.Warnf("Couldn't stat target %v: %v", target, err)
Expand Down
10 changes: 5 additions & 5 deletions internal/snmp/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ type RTableRow struct {

// Init() builds & initializes the nested fields.
func (t *Table) Init(tr Translator) error {
//makes sure oid or name is set in config file
//otherwise snmp will produce metrics with an empty name
// makes sure oid or name is set in config file
// otherwise snmp will produce metrics with an empty name
if t.Oid == "" && t.Name == "" {
return errors.New("SNMP table in config file is not named. One or both of the oid and name settings must be set")
}
Expand Down Expand Up @@ -120,7 +120,7 @@ func (t *Table) initBuild() error {
func (t Table) Build(gs Connection, walk bool) (*RTable, error) {
rows := map[string]RTableRow{}

//translation table for secondary index (when performing join on two tables)
// translation table for secondary index (when performing join on two tables)
secIdxTab := make(map[string]string)
secGlobalOuterJoin := false
for i, f := range t.Fields {
Expand Down Expand Up @@ -262,7 +262,7 @@ func (t Table) Build(gs Connection, walk bool) (*RTable, error) {
rtr.Fields[f.Name] = v
}
if f.SecondaryIndexTable {
//indexes are stored here with prepending "." so we need to add them if needed
// indexes are stored here with prepending "." so we need to add them if needed
var vss string
if ok {
vss = "." + vs
Expand All @@ -281,7 +281,7 @@ func (t Table) Build(gs Connection, walk bool) (*RTable, error) {

rt := RTable{
Name: t.Name,
Time: time.Now(), //TODO record time at start
Time: time.Now(), // TODO record time at start
Rows: make([]RTableRow, 0, len(rows)),
}
for _, r := range rows {
Expand Down
6 changes: 3 additions & 3 deletions internal/snmp/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestTableJoinNoIndexAsTag_walk(t *testing.T) {
Tags: map[string]string{
"myfield1": "instance",
"myfield4": "bar",
//"index": "10",
// "index": "10",
},
Fields: map[string]interface{}{
"myfield2": 10,
Expand All @@ -221,7 +221,7 @@ func TestTableJoinNoIndexAsTag_walk(t *testing.T) {
rtr2 := RTableRow{
Tags: map[string]string{
"myfield1": "instance2",
//"index": "11",
// "index": "11",
},
Fields: map[string]interface{}{
"myfield2": 20,
Expand All @@ -232,7 +232,7 @@ func TestTableJoinNoIndexAsTag_walk(t *testing.T) {
rtr3 := RTableRow{
Tags: map[string]string{
"myfield1": "instance3",
//"index": "12",
// "index": "12",
},
Fields: map[string]interface{}{
"myfield2": 20,
Expand Down
6 changes: 3 additions & 3 deletions internal/snmp/translator_gosmi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ func TestTableJoinNoIndexAsTag_walkGosmi(t *testing.T) {
Tags: map[string]string{
"myfield1": "instance",
"myfield4": "bar",
//"index": "10",
// "index": "10",
},
Fields: map[string]interface{}{
"myfield2": 10,
Expand All @@ -571,7 +571,7 @@ func TestTableJoinNoIndexAsTag_walkGosmi(t *testing.T) {
rtr2 := RTableRow{
Tags: map[string]string{
"myfield1": "instance2",
//"index": "11",
// "index": "11",
},
Fields: map[string]interface{}{
"myfield2": 20,
Expand All @@ -582,7 +582,7 @@ func TestTableJoinNoIndexAsTag_walkGosmi(t *testing.T) {
rtr3 := RTableRow{
Tags: map[string]string{
"myfield1": "instance3",
//"index": "12",
// "index": "12",
},
Fields: map[string]interface{}{
"myfield2": 20,
Expand Down
2 changes: 1 addition & 1 deletion internal/snmp/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// We interact through an interface so we can mock it out in tests.
type Connection interface {
Host() string
//BulkWalkAll(string) ([]gosnmp.SnmpPDU, error)
// BulkWalkAll(string) ([]gosnmp.SnmpPDU, error)
Walk(string, gosnmp.WalkFunc) error
Get(oids []string) (*gosnmp.SnmpPacket, error)
Reconnect() error
Expand Down
2 changes: 1 addition & 1 deletion logger/event_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestRestrictedEventLogIntegration(t *testing.T) {
}
require.NoError(t, SetupLogging(config))

//separate previous log messages by small delay
// separate previous log messages by small delay
time.Sleep(time.Second)
now := time.Now()
log.Println("I! Info message")
Expand Down
4 changes: 2 additions & 2 deletions models/running_output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func BenchmarkRunningOutputAddWrite(b *testing.B) {

for n := 0; n < b.N; n++ {
ro.AddMetric(testutil.TestMetric(101, "metric1"))
ro.Write() //nolint: errcheck // skip checking err for benchmark tests
ro.Write() //nolint:errcheck // skip checking err for benchmark tests
}
}

Expand All @@ -58,7 +58,7 @@ func BenchmarkRunningOutputAddWriteEvery100(b *testing.B) {
for n := 0; n < b.N; n++ {
ro.AddMetric(testutil.TestMetric(101, "metric1"))
if n%100 == 0 {
ro.Write() //nolint: errcheck // skip checking err for benchmark tests
ro.Write() //nolint:errcheck // skip checking err for benchmark tests
}
}
}
Expand Down
Loading

0 comments on commit 43590ca

Please sign in to comment.