Skip to content

Commit eea8fd3

Browse files
chhawchhariaHarness
authored andcommitted
feat:[CI-13780]: Fixed lint issues (#379)
* feat:[CI-13780]: Fixed lint issues
1 parent 65d1c72 commit eea8fd3

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

engine/pids/pidfile.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ import (
1212
"time"
1313
)
1414

15+
const (
16+
// filePermission defines the permission for creating/writing PID files
17+
filePermission = 0644
18+
)
19+
1520
// ReadPIDsFromFile reads process IDs (PIDs) from a file at the specified path.
1621
// The file should contain PIDs as comma-separated values.
1722
// It returns a slice of integers representing the PIDs.
@@ -109,7 +114,7 @@ func AppendPIDToFile(pid int, path string) error {
109114
}
110115

111116
// Open file for appending, create if it doesn't exist
112-
file, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
117+
file, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, filePermission)
113118
if err != nil {
114119
return fmt.Errorf("failed to open file %s: %w", path, err)
115120
}
@@ -119,9 +124,9 @@ func AppendPIDToFile(pid int, path string) error {
119124
var content string
120125
if fileExists {
121126
// If file exists, check if it's empty or needs a comma separator
122-
fileInfo, err := file.Stat()
123-
if err != nil {
124-
return fmt.Errorf("failed to get file info: %w", err)
127+
fileInfo, statErr := file.Stat()
128+
if statErr != nil {
129+
return fmt.Errorf("failed to get file info: %w", statErr)
125130
}
126131

127132
if fileInfo.Size() > 0 {
@@ -212,13 +217,13 @@ func killProcessWithGracePeriod(pid int, timeout time.Duration) error {
212217
// Wait for the process to exit or timeout to expire
213218
done := make(chan error)
214219
go func() {
215-
_, err := process.Wait()
216-
done <- err
220+
_, waitErr := process.Wait()
221+
done <- waitErr
217222
}()
218223
select {
219-
case err := <-done:
220-
if err != nil {
221-
return err
224+
case waitErr := <-done:
225+
if waitErr != nil {
226+
return waitErr
222227
}
223228
return nil
224229
case <-time.After(timeout):

engine/spec/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type (
2121
EnableDockerSetup *bool `json:"mount_docker_socket"`
2222
TTY bool `json:"tty,omitempty" default:"false"`
2323
MtlsConfig MtlsConfig `json:"mtls_config,omitempty"`
24-
ProcessIdsFilePath string `json:"process_ids_file_path,omitempty"` // Path to the file where process IDs are stored. Process IDs are used to track running processes launched by run step on host.
24+
ProcessIdsFilePath string `json:"process_ids_file_path,omitempty"` // Path to the file where process IDs are stored. Process IDs are used to track running processes launched by run step on host. //nolint:lll
2525
}
2626

2727
// Step defines a pipeline step.

logstream/replacer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ func NewReplacer(w Writer, secrets []string) Writer {
195195

196196
// NewReplacerWithEnvs returns a replacer that wraps io.Writer w with environment variable support.
197197
// If CI_ENABLE_EXTRA_CHARACTERS_SECRETS_MASKING is set to "true" in envs, uses advanced variant creation.
198-
func NewReplacerWithEnvs(w Writer, secrets []string, envs map[string]string) Writer {
198+
func NewReplacerWithEnvs(w Writer, secrets []string, envs map[string]string) Writer { //nolint:gocyclo
199199
// Check if advanced secret masking is enabled
200200
useAdvancedMasking := false
201201
if envs != nil {

pipeline/runtime/runtestsV2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ func getTestsSelection(ctx context.Context, fs filesystem.FileSystem, stepID, wo
280280
}
281281

282282
func getTestsSelectionWithTiModeEnabled(ctx context.Context, fs filesystem.FileSystem, stepID, workspace string, log *logrus.Logger,
283-
isManual bool, tiConfig *tiCfg.Cfg, envs map[string]string, runV2Config *api.RunTestsV2Config, testGlobs []string) (types.SelectTestsResp, bool) {
283+
isManual bool, tiConfig *tiCfg.Cfg, envs map[string]string, runV2Config *api.RunTestsV2Config, testGlobs []string) (types.SelectTestsResp, bool) { //nolint:unparam
284284
selection := types.SelectTestsResp{}
285285
// Question : Here i can see feature state is being defined in Runtest but here we don't have runOnlySelected tests so should we always defined as optimized state
286286
var files []types.File

0 commit comments

Comments
 (0)