Skip to content

Commit

Permalink
Apply Pull Request suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
oleiade committed Jan 31, 2025
1 parent 895103c commit b3208dc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/js/modules/k6/experimental/csv/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func NewReaderFrom(r io.Reader, options options) (*Reader, error) {
options: options,
}

headerEnabled := options.AsObjects.Valid && options.AsObjects.Bool
if headerEnabled {
asObjectsEnabled := options.AsObjects.Valid && options.AsObjects.Bool
if asObjectsEnabled {
header, err := csvParser.Read()
if err != nil {
return nil, fmt.Errorf("failed to read the first line; reason: %w", err)
Expand Down Expand Up @@ -134,14 +134,14 @@ func validateOptions(options options) error {
fromLineSet = options.FromLine.Valid
toLineSet = options.ToLine.Valid
skipFirstLineSet = options.SkipFirstLine
headerEnabled = options.AsObjects.Valid && options.AsObjects.Bool
asObjectsEnabled = options.AsObjects.Valid && options.AsObjects.Bool
)

if headerEnabled && skipFirstLineSet {
if asObjectsEnabled && skipFirstLineSet {
return fmt.Errorf("the 'header' option cannot be enabled when 'skipFirstLine' is true")
}

if headerEnabled && fromLineSet && options.FromLine.Int64 > 0 {
if asObjectsEnabled && fromLineSet && options.FromLine.Int64 > 0 {
return fmt.Errorf("the 'header' option cannot be enabled when 'fromLine' is set to a value greater than 0")
}

Expand Down

0 comments on commit b3208dc

Please sign in to comment.