sas-linter 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4552996a6f33196d26f85d2cd057c525f8aff278b2e4d26791d0295bc5b49ccc
4
- data.tar.gz: 72b2f4a69e108b29818cb686b8ffb135768547a0d68a09086a5d4946524af17d
3
+ metadata.gz: 144b602b9b4eff14c301d9c04852f07f490e9557802f897eb4dd08acbf3d3fa4
4
+ data.tar.gz: 4aa7e953e1ed8a05cd1f4b94cf698086438a529604019120be0bcc0bb0530be3
5
5
  SHA512:
6
- metadata.gz: 1efcbb6cf7707971d58ae82089df387a309e5f5941d9a90b72075c1cfa8af660bc21d9089f5d42b72b428b8669535334eb6b1f1bd22967738a58a1057f0d7614
7
- data.tar.gz: 6c37528f85bd94d51020b08fb1685a20a1dd1e0eded7a2949c27c57b21b1b4b5204036220826b39e198e6b6c92160634ccbd7bc3b79b657b834a9a1e666233bd
6
+ metadata.gz: 74e7303ebdcfcfc616cd6e520f8984494d687b3c0c3af6dcba4efba91f7cbfefd61f511bfa535ae4ee9c4f6a481d4774a96b7a4ff20803ce2768782f2b39f5e6
7
+ data.tar.gz: 7a1dab42267ac076c9d992d7770871c386d52d6f4c6c2cc088372151b6f586e1ff12b963dcab26a47aa0b427396eef989c9f837805a4183e35c43a734b8fbd41
@@ -61,9 +61,19 @@ class SasLinter
61
61
  def autofix(source)
62
62
  return source if source.nil? || source.empty?
63
63
 
64
+ # If a previous rule's autofix returned ASCII-8BIT (e.g.
65
+ # EncodingIssues#autofix walks bytes and returns binary), tag
66
+ # it UTF-8 before slicing. The lexer treats the bytes as UTF-8
67
+ # and reports character offsets either way; only Ruby's
68
+ # `String#[]=` cares about the encoding label, and it indexes
69
+ # by bytes for ASCII-8BIT but by characters for UTF-8 — so a
70
+ # binary tag plus any multi-byte sequence earlier in the file
71
+ # would shift every replacement by the byte/char gap.
72
+ src = source.encoding == Encoding::UTF_8 ? source : source.dup.force_encoding("UTF-8")
73
+
64
74
  lexer = SasLexer::Lexer.new
65
75
  begin
66
- all_tokens = lexer.tokenize(source)
76
+ all_tokens = lexer.tokenize(src)
67
77
  ensure
68
78
  lexer.free
69
79
  end
@@ -78,7 +88,7 @@ class SasLinter
78
88
  end
79
89
 
80
90
  # Apply right-to-left so earlier offsets stay valid.
81
- out = source.dup
91
+ out = src.dup
82
92
  edits.sort_by! { |start, _, _| -start }
83
93
  edits.each { |start, finish, repl| out[start...finish] = repl }
84
94
  out
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class SasLinter
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sas-linter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig McNamara