csvlint 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d15e75580e44bba3f1f8965b348f0ccfe088c6fb60e881b9f997c99fc05a7cc
4
- data.tar.gz: 0bdf3cbec5a855f68abec7c2dccaa4f90db70955459044f7cfc67cbec963f9b8
3
+ metadata.gz: ad0e814a8366671d93eb767885e657827a84456f6c141a02e7dbe5ba5bcb1892
4
+ data.tar.gz: 90abebb42e77c1a49e61eb151459f5ea0b98539b0f0415b87e924b63e226aaa0
5
5
  SHA512:
6
- metadata.gz: 0c86225f94173f87c44bd337975b3716c9b1ec629aa6d784e4b309724655d2af5eaa118fda1d1f139f0d6a432cfeb1536e7076603a2a4b0e94fe18278d28dcb9
7
- data.tar.gz: 4986940f1b2d928d85ae65b01a8c2c3eede4f352218a5ad18aa761a153fcd0a1530189e418a1e38aa4c0544c998f19944a8de290ef924d6f539d959fa2dcca8f
6
+ metadata.gz: 9d8d5462bc0c4306c308dde03264adad8c820bd1fe3d559e970210cdd809806d11a4fc5bea1830e5582774776edb3758f5d78fd4e7fe4c636872afaa4c00a236
7
+ data.tar.gz: 654659368878f232e0cbc6fa036343a39ac99a141c260ee552e90316f1a8d4a6e18c4ebba43200e7315dd71452602375d76b28cc5da934db6224e0c5239bceda
@@ -10,13 +10,14 @@ jobs:
10
10
  runs-on: ubuntu-latest
11
11
  strategy:
12
12
  matrix:
13
- ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
13
+ ruby-version: ['2.5', '2.6', '2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
14
14
  activesupport-version:
15
15
  - activesupport_5.2
16
16
  - activesupport_6.0
17
17
  - activesupport_6.1
18
18
  - activesupport_7.0
19
19
  - activesupport_7.1
20
+ - activesupport_7.2
20
21
  exclude:
21
22
  - ruby-version: '2.5'
22
23
  activesupport-version: activesupport_7.0
@@ -26,6 +27,14 @@ jobs:
26
27
  activesupport-version: activesupport_7.1
27
28
  - ruby-version: '2.6'
28
29
  activesupport-version: activesupport_7.1
30
+ - ruby-version: '2.5'
31
+ activesupport-version: activesupport_7.2
32
+ - ruby-version: '2.6'
33
+ activesupport-version: activesupport_7.2
34
+ - ruby-version: '2.7'
35
+ activesupport-version: activesupport_7.2
36
+ - ruby-version: '3.0'
37
+ activesupport-version: activesupport_7.2
29
38
  fail-fast: false
30
39
 
31
40
  env:
@@ -49,7 +58,7 @@ jobs:
49
58
  - uses: ruby/setup-ruby@v1
50
59
  with:
51
60
  bundler-cache: true
52
- ruby-version: "3.3"
61
+ ruby-version: "3.4"
53
62
  - name: Install dependencies
54
63
  run: bundle install
55
64
  - name: Run the tests
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.0
1
+ 3.4.1
data/.standard_todo.yml CHANGED
@@ -13,7 +13,6 @@ ignore:
13
13
  - Style/IdenticalConditionalBranches
14
14
  - lib/csvlint/csvw/property_checker.rb:
15
15
  - Performance/InefficientHashSearch
16
- - Lint/UselessAssignment
17
16
  - Naming/VariableName
18
17
  - Style/SlicingWithRange
19
18
  - Security/Open
@@ -24,18 +23,16 @@ ignore:
24
23
  - Naming/VariableName
25
24
  - lib/csvlint/schema.rb:
26
25
  - Security/Open
27
- - Lint/UselessAssignment
28
26
  - Style/SlicingWithRange
29
27
  - lib/csvlint/validate.rb:
30
- - Lint/UselessAssignment
31
28
  - Performance/Count
32
29
  - Lint/BooleanSymbol
33
30
  - Naming/VariableName
34
31
  - Security/Open
35
32
  - Lint/NonLocalExitFromIterator
36
- - spec/validator_spec.rb:
37
- - Lint/UselessAssignment
38
33
  - lib/csvlint/schema.rb:
39
34
  - Lint/UselessRescue
40
35
  - lib/csvlint/validate.rb:
41
36
  - Lint/UselessRescue
37
+ - lib/csvlint/cli.rb:
38
+ - Style/SafeNavigation
data/Appraisals CHANGED
@@ -20,3 +20,7 @@ end
20
20
  appraise "activesupport_7.1" do
21
21
  gem "activesupport", "~> 7.1.0"
22
22
  end
23
+
24
+ appraise "activesupport_7.2" do
25
+ gem "activesupport", "~> 7.2.0"
26
+ end
data/README.md CHANGED
@@ -17,7 +17,7 @@ A ruby gem to support validating CSV files to check their syntax and contents. Y
17
17
 
18
18
  ## Development
19
19
 
20
- `ruby version 3.3`
20
+ `ruby version 3.4`
21
21
 
22
22
  ### Tests
23
23
 
data/csvlint.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.required_ruby_version = [">= 2.5", "< 3.4"]
19
+ spec.required_ruby_version = [">= 2.5", "< 3.5"]
20
20
 
21
21
  spec.add_dependency "csv"
22
22
  spec.add_dependency "rainbow"
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "thor"
30
30
  spec.add_dependency "rack"
31
31
  spec.add_dependency "net-http-persistent"
32
+ spec.add_dependency "mutex_m" # For Ruby 3.4+
32
33
 
33
34
  spec.add_development_dependency "bundler", ">= 1.3"
34
35
  spec.add_development_dependency "rake"
@@ -40,13 +41,12 @@ Gem::Specification.new do |spec|
40
41
  spec.add_development_dependency "rspec"
41
42
  spec.add_development_dependency "rspec-pride"
42
43
  spec.add_development_dependency "rspec-expectations"
43
- spec.add_development_dependency "coveralls"
44
+ spec.add_development_dependency "coveralls_reborn"
44
45
  spec.add_development_dependency "byebug"
45
46
  spec.add_development_dependency "github_changelog_generator"
46
47
  spec.add_development_dependency "aruba"
47
48
  spec.add_development_dependency "rdf", "< 4.0"
48
49
  spec.add_development_dependency "rdf-turtle"
49
- spec.add_development_dependency "henry"
50
50
  spec.add_development_dependency "standardrb"
51
51
  spec.add_development_dependency "appraisal"
52
52
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 7.2.0"
6
+
7
+ gemspec path: "../"
data/lib/csvlint/cli.rb CHANGED
@@ -104,7 +104,7 @@ module Csvlint
104
104
  location = "#{error.row ? "Row" : "Column"}: #{location}"
105
105
  end
106
106
  output_string = "#{index + 1}. "
107
- if error.column && @schema && @schema.instance_of?(Csvlint::Schema)
107
+ if error.column && @schema&.instance_of?(Csvlint::Schema)
108
108
  unless @schema.fields[error.column - 1].nil?
109
109
  output_string += "#{@schema.fields[error.column - 1].name}: "
110
110
  end
@@ -176,7 +176,7 @@ module Csvlint
176
176
  col: error.column
177
177
  }
178
178
 
179
- if error.column && @schema && @schema.instance_of?(Csvlint::Schema) && !@schema.fields[error.column - 1].nil?
179
+ if error.column && @schema&.instance_of?(Csvlint::Schema) && !@schema.fields[error.column - 1].nil?
180
180
  field = @schema.fields[error.column - 1]
181
181
  h[:header] = field.name
182
182
  h[:constraints] = field.constraints.map { |k, v| [k.underscore, v] }.to_h
@@ -285,8 +285,8 @@ module Csvlint
285
285
  warnings = []
286
286
  if value.instance_of? Hash
287
287
  if value["@id"]
288
- raise Csvlint::Csvw::MetadataError.new("datatype.@id"), "datatype @id must not be the id of a built-in datatype (#{value["@id"]})" if BUILT_IN_DATATYPES.values.include?(value["@id"])
289
- v, w, t = PROPERTIES["@id"].call(value["@id"], base_url, lang)
288
+ raise Csvlint::Csvw::MetadataError.new("datatype.@id"), "datatype @id must not be the id of a built-in datatype (#{value["@id"]})" if BUILT_IN_DATATYPES.value?(value["@id"])
289
+ _, w, _ = PROPERTIES["@id"].call(value["@id"], base_url, lang)
290
290
  unless w.nil?
291
291
  warnings << w
292
292
  value.delete("@id")
@@ -422,7 +422,7 @@ module Csvlint
422
422
  elsif p == "url"
423
423
  elsif p == "titles"
424
424
  else
425
- v, warning, type = check_property(p, v, base_url, lang)
425
+ _, warning, type = check_property(p, v, base_url, lang)
426
426
  if type != :transformation && !(warning.nil? || warning.empty?)
427
427
  value.delete(p)
428
428
  warnings << :invalid_property unless type == :transformation
@@ -555,7 +555,7 @@ module Csvlint
555
555
  warnings = []
556
556
  value.each do |p, v|
557
557
  if ["resource", "schemaReference", "columnReference"].include? p
558
- v, warning, type = check_property(p, v, base_url, lang)
558
+ v, warning, _ = check_property(p, v, base_url, lang)
559
559
  if warning.nil? || warning.empty?
560
560
  value[p] = v
561
561
  else
data/lib/csvlint/field.rb CHANGED
@@ -82,6 +82,12 @@ module Csvlint
82
82
  @uniques << value
83
83
  end
84
84
  end
85
+
86
+ if constraints["enum"]
87
+ unless constraints["enum"].include?(value)
88
+ build_errors(:invalid_enum_value, :schema, row, column, value, {"enum" => constraints["enum"]})
89
+ end
90
+ end
85
91
  end
86
92
 
87
93
  def validate_type(value, row, column)
@@ -48,7 +48,7 @@ module Csvlint
48
48
  else
49
49
  Schema.from_json_table(uri, json)
50
50
  end
51
- rescue TypeError => e
51
+ rescue TypeError
52
52
  # NO IDEA what this was even trying to do - SP 20160526
53
53
  rescue Csvlint::Csvw::MetadataError => e
54
54
  raise e
@@ -88,7 +88,7 @@ module Csvlint
88
88
 
89
89
  fields.each_with_index do |field, i|
90
90
  value = values[i] || ""
91
- result = field.validate_column(value, row, i + 1, all_errors)
91
+ field.validate_column(value, row, i + 1, all_errors)
92
92
  @errors += fields[i].errors
93
93
  @warnings += fields[i].warnings
94
94
  end
@@ -157,7 +157,7 @@ module Csvlint
157
157
  # If it's not a full line, then prepare to add it to the beginning of the next chunk
158
158
  @leading = line
159
159
  end
160
- rescue ArgumentError => ae
160
+ rescue ArgumentError
161
161
  build_errors(:invalid_encoding, :structure, @current_line, nil, @current_line) unless @reported_invalid_encoding
162
162
  @current_line += 1
163
163
  @reported_invalid_encoding = true
@@ -165,13 +165,12 @@ module Csvlint
165
165
 
166
166
  def validate_line(input = nil, index = nil)
167
167
  @input = input
168
- single_col = false
169
168
  line = index.present? ? index : 0
170
169
  @encoding = input.encoding.to_s
171
170
  report_line_breaks(line)
172
171
  parse_contents(input, line)
173
172
  @lambda&.call(self)
174
- rescue ArgumentError => ae
173
+ rescue ArgumentError
175
174
  build_errors(:invalid_encoding, :structure, @current_line, nil, index) unless @reported_invalid_encoding
176
175
  @reported_invalid_encoding = true
177
176
  end
@@ -205,7 +204,7 @@ module Csvlint
205
204
  if @schema
206
205
  @schema.validate_row(row, current_line, all_errors, @source, @validate)
207
206
  @errors += @schema.errors
208
- all_errors += @schema.errors
207
+ @schema.errors
209
208
  @warnings += @schema.warnings
210
209
  elsif !row.empty? && row.size != @expected_columns
211
210
  build_errors(:ragged_rows, :structure, current_line, nil, stream.to_s)
@@ -277,7 +276,6 @@ module Csvlint
277
276
  if schema.tables[@source_url]
278
277
  @schema = schema
279
278
  else
280
- warn_if_unsuccessful = true
281
279
  build_warnings(:schema_mismatch, :context, nil, nil, @source_url, schema)
282
280
  end
283
281
  end
@@ -1,3 +1,3 @@
1
1
  module Csvlint
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
data/lib/csvlint.rb CHANGED
@@ -4,7 +4,7 @@ require "open-uri"
4
4
  require "tempfile"
5
5
  require "typhoeus"
6
6
 
7
- require "active_support"
7
+ require "active_support/all"
8
8
  require "open_uri_redirections"
9
9
  require "uri_template"
10
10
 
@@ -573,14 +573,14 @@ describe Csvlint::Validator do
573
573
  it "should call a lambda for each line" do
574
574
  @count = 0
575
575
  mylambda = lambda { |row| @count += 1 }
576
- validator = Csvlint::Validator.new(File.new(File.join(File.dirname(__FILE__), "..", "features", "fixtures", "valid.csv")), {}, nil, {lambda: mylambda})
576
+ Csvlint::Validator.new(File.new(File.join(File.dirname(__FILE__), "..", "features", "fixtures", "valid.csv")), {}, nil, {lambda: mylambda})
577
577
  expect(@count).to eq(3)
578
578
  end
579
579
 
580
580
  it "reports back the status of each line" do
581
581
  @results = []
582
582
  mylambda = lambda { |row| @results << row.current_line }
583
- validator = Csvlint::Validator.new(File.new(File.join(File.dirname(__FILE__), "..", "features", "fixtures", "valid.csv")), {}, nil, {lambda: mylambda})
583
+ Csvlint::Validator.new(File.new(File.join(File.dirname(__FILE__), "..", "features", "fixtures", "valid.csv")), {}, nil, {lambda: mylambda})
584
584
  expect(@results.count).to eq(3)
585
585
  expect(@results[0]).to eq(1)
586
586
  expect(@results[1]).to eq(2)
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csvlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pezholio
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-04-13 00:00:00.000000000 Z
10
+ date: 2025-01-17 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: csv
@@ -164,6 +163,20 @@ dependencies:
164
163
  - - ">="
165
164
  - !ruby/object:Gem::Version
166
165
  version: '0'
166
+ - !ruby/object:Gem::Dependency
167
+ name: mutex_m
168
+ requirement: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ type: :runtime
174
+ prerelease: false
175
+ version_requirements: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
167
180
  - !ruby/object:Gem::Dependency
168
181
  name: bundler
169
182
  requirement: !ruby/object:Gem::Requirement
@@ -305,7 +318,7 @@ dependencies:
305
318
  - !ruby/object:Gem::Version
306
319
  version: '0'
307
320
  - !ruby/object:Gem::Dependency
308
- name: coveralls
321
+ name: coveralls_reborn
309
322
  requirement: !ruby/object:Gem::Requirement
310
323
  requirements:
311
324
  - - ">="
@@ -388,20 +401,6 @@ dependencies:
388
401
  - - ">="
389
402
  - !ruby/object:Gem::Version
390
403
  version: '0'
391
- - !ruby/object:Gem::Dependency
392
- name: henry
393
- requirement: !ruby/object:Gem::Requirement
394
- requirements:
395
- - - ">="
396
- - !ruby/object:Gem::Version
397
- version: '0'
398
- type: :development
399
- prerelease: false
400
- version_requirements: !ruby/object:Gem::Requirement
401
- requirements:
402
- - - ">="
403
- - !ruby/object:Gem::Version
404
- version: '0'
405
404
  - !ruby/object:Gem::Dependency
406
405
  name: standardrb
407
406
  requirement: !ruby/object:Gem::Requirement
@@ -508,6 +507,7 @@ files:
508
507
  - gemfiles/activesupport_6.1.gemfile
509
508
  - gemfiles/activesupport_7.0.gemfile
510
509
  - gemfiles/activesupport_7.1.gemfile
510
+ - gemfiles/activesupport_7.2.gemfile
511
511
  - lib/csvlint.rb
512
512
  - lib/csvlint/cli.rb
513
513
  - lib/csvlint/csvw/column.rb
@@ -536,7 +536,6 @@ homepage: https://github.com/theodi/csvlint.rb
536
536
  licenses:
537
537
  - MIT
538
538
  metadata: {}
539
- post_install_message:
540
539
  rdoc_options: []
541
540
  require_paths:
542
541
  - lib
@@ -547,15 +546,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
547
546
  version: '2.5'
548
547
  - - "<"
549
548
  - !ruby/object:Gem::Version
550
- version: '3.4'
549
+ version: '3.5'
551
550
  required_rubygems_version: !ruby/object:Gem::Requirement
552
551
  requirements:
553
552
  - - ">="
554
553
  - !ruby/object:Gem::Version
555
554
  version: '0'
556
555
  requirements: []
557
- rubygems_version: 3.5.3
558
- signing_key:
556
+ rubygems_version: 3.6.2
559
557
  specification_version: 4
560
558
  summary: CSV Validator
561
559
  test_files: []