Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FMotalleb committed Jun 28, 2024
1 parent 8c5bdd2 commit 04b5bac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 53 deletions.
11 changes: 7 additions & 4 deletions cmd/parser/cron_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func NewCronFromFile(filePath string) CronString {
log.Panicf("can't open cron file: %v", err)
}
stat, err := file.Stat()
if err != nil {
log.Panicf("can't stat cron file: %v", err)
}
content := make([]byte, stat.Size())
file.Read(content)

Check failure on line 33 in cmd/parser/cron_string.go

View workflow job for this annotation

GitHub Actions / analyze (go)

Error return value of `file.Read` is not checked (errcheck)

Check failure on line 33 in cmd/parser/cron_string.go

View workflow job for this annotation

GitHub Actions / analyze (go)

Error return value of `file.Read` is not checked (errcheck)

Check failure on line 33 in cmd/parser/cron_string.go

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest)

Error return value of `file.Read` is not checked (errcheck)

Check failure on line 33 in cmd/parser/cron_string.go

View workflow job for this annotation

GitHub Actions / ci (macos-latest)

Error return value of `file.Read` is not checked (errcheck)

Check failure on line 33 in cmd/parser/cron_string.go

View workflow job for this annotation

GitHub Actions / ci (windows-latest)

Error return value of `file.Read` is not checked (errcheck)
return CronString{string(content)}
Expand Down Expand Up @@ -70,13 +73,13 @@ func (s CronString) lines() []string {
return strings.Split(s.string, "\n")
}

func (c *CronString) parseAsSpec(
func (s *CronString) parseAsSpec(
pattern string,
hasUser bool,
) []cronSpec {
envTable := make(map[string]string)
specs := make([]cronSpec, 0)
lines := c.sanitize().lines()
lines := s.sanitize().lines()
matcher, parser := buildMapper(hasUser, pattern)

for _, line := range lines {
Expand All @@ -98,11 +101,11 @@ func (c *CronString) parseAsSpec(
return specs
}

func (c *CronString) ParseConfig(
func (s *CronString) ParseConfig(
pattern string,
hasUser bool,
) *config.Config {
specs := c.parseAsSpec(pattern, hasUser)
specs := s.parseAsSpec(pattern, hasUser)
cfg := &config.Config{}
for _, spec := range specs {
addSpec(cfg, spec)
Expand Down
2 changes: 2 additions & 0 deletions cmd/parser/parser.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package parser manages holds the logic behind the sub command `parse`
// this package is responsible for parsing a crontab file into valid config yaml file
package parser

import (
Expand Down
49 changes: 0 additions & 49 deletions test.yaml

This file was deleted.

0 comments on commit 04b5bac

Please sign in to comment.