harri 0.1.2 → 0.1.4

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: 32a2af9d55b5ccf09c7be859a562bc47e554cbb7b5bd7563b16c2549318edb84
4
- data.tar.gz: 0d30ec8cb5435ae41653c9be040d97df1238ba1ac4b87c68169deccb6fa53d13
3
+ metadata.gz: f97d86dc002eed2bd9e3d9664541fe54b16643a87b4080556c22a19db863036d
4
+ data.tar.gz: cfb2ed9c3443be16ebf105dbf91e9c2b0c9001390f7f4d30db73393827336011
5
5
  SHA512:
6
- metadata.gz: f92790d7879290fdfccac41660864784366f2d616401a74852727bba1eab66b41730d4dd6b7705c61060233f377ddad7a91de0c97084160442fd8c6733baa91d
7
- data.tar.gz: c3e684620fd0baf358dbfec6c321e05ef41befc95b4a02665a2cff69c82f37ce905573973ff698c63e97cf8e79394da603a09fdaf61089ad1493b33ffe5581db
6
+ metadata.gz: a5f1aadedf04486fe4cd68ef5f26a8c91f929427af371439b42ff1fc66561854ee48d6cd135121dbbe4cb9a2401b2ead05d2b048b7524e55419ed2a1ac206fb2
7
+ data.tar.gz: 931469f5823707b7fd41e2da609f407e5328a2dc69d9fbc9a318c0c3b5b71f2dc271aa39263c080ef95076400db81930d0ff4e6ed9e69b3874f01501c4c906ad
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- harri (0.1.2)
4
+ harri (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,6 +10,7 @@ GEM
10
10
  rake (13.0.6)
11
11
 
12
12
  PLATFORMS
13
+ universal-darwin-22
13
14
  x86_64-linux
14
15
 
15
16
  DEPENDENCIES
@@ -18,4 +19,4 @@ DEPENDENCIES
18
19
  rake (~> 13.0)
19
20
 
20
21
  BUNDLED WITH
21
- 2.3.26
22
+ 2.4.18
@@ -15,12 +15,16 @@ module Harri
15
15
  # There are no imports, so the whole module is redundant.
16
16
  text.sub(/^#{Regexp.quote(match[0])}/, "")
17
17
  else
18
+ module_imports = match[1]
19
+ return text if !module_imports
20
+
18
21
  # Filter out specific imports within the module.
19
- filtered_imports = import_info[:imports].reduce(match[0]) do |result, import|
22
+ filtered_imports = import_info[:imports].reduce(module_imports) do |result, import|
20
23
  reference_regex = Harri::Regexes.named_reference_regex import
21
24
  result.sub reference_regex, ""
22
25
  end
23
- text.sub match[0], filtered_imports
26
+ replaced_imports = match[0].sub module_imports, filtered_imports
27
+ text.sub match[0], replaced_imports
24
28
  end
25
29
  end
26
30
  end
data/lib/harri/regexes.rb CHANGED
@@ -2,13 +2,13 @@ module Harri
2
2
  module Regexes
3
3
  # Intended to capture the first line of an error within GHC's output.
4
4
  START_ERROR_REGEX = %r{
5
- (.*\.hs) # filename
6
- : # literal colon
7
- \d+ # line number
8
- : # literal colon
9
- \d+ # column number
10
- : # literal colon
11
- \s # space
5
+ (.*\.hs) # filename
6
+ : # literal colon
7
+ \d+ # line number
8
+ : # literal colon
9
+ (\d+)(?:-(\d+))? # column number
10
+ : # literal colon
11
+ \s # space
12
12
  error:.* # literal "error:" with possible marker
13
13
  }x
14
14
 
@@ -18,7 +18,7 @@ module Harri
18
18
  : # literal colon
19
19
  \d+ # line number
20
20
  : # literal colon
21
- \d+ # column number
21
+ (\d+)(?:-(\d+))? # column number
22
22
  : # literal colon
23
23
  \s # space
24
24
  error: # literal "error:"
@@ -28,7 +28,7 @@ module Harri
28
28
  }x
29
29
 
30
30
  # Intended to capture the scenario when an entire module is redundant.
31
- ENTIRE_MODULE_REDUNDANT_REGEX = /The(?: qualified)? import of ‘(.+)’ is redundant except.*/
31
+ ENTIRE_MODULE_REDUNDANT_REGEX =/The(?: qualified)? import of ‘([^’]+)’ is redundant(?!.*from module)/
32
32
 
33
33
  # Intended to capture the scenario when specific imports within a module are redundant.
34
34
  REDUNDANT_IMPORTS_WITHIN_MODULE_REGEX = /The import of ‘(.+)’ from module ‘(.+)’ is redundant.*/
@@ -44,7 +44,7 @@ module Harri
44
44
  (?:qualified\s*)? # zero or one literal "qualified" with optional space afterwards
45
45
  (?:as\s+[A-Z]+[a-zA-Z0-9.]*\s*)? # zero or one literal "as `module_name`" with optional space afterwards
46
46
  (?:hiding\s*)? # zero or one literal "hiding" with optional space afterwards
47
- (?:(\((?>[^)(]+|\g<1>)*\)))? # zero or one list of imports (see https://stackoverflow.com/a/35271017)
47
+ ((\((?>[^)(]+|\g<1>)*\)))? # zero or one list of imports (see https://stackoverflow.com/a/35271017)
48
48
  \n? # zero or one linebreak
49
49
  }x
50
50
  end
@@ -53,6 +53,7 @@ module Harri
53
53
  def self.named_reference_regex(reference)
54
54
  %r{
55
55
  \b#{Regexp.quote reference}\b # match "`reference`" exactly as a single word
56
+ (?:\s*\(\.\.\))? # zero or one instances of optional space followed by a literal "(..)"
56
57
  (?:\s*,?)? # zero or one instances of optional space followed by zero or one comma
57
58
  \s* # optional space
58
59
  }x
data/lib/harri/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Harri
4
4
  module Version
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - rhizomic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-03 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'Harri: HAskell Remove Redundant Imports. A way to get GHC to stop harrying
14
14
  you about them.'
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  - !ruby/object:Gem::Version
57
57
  version: '0'
58
58
  requirements: []
59
- rubygems_version: 3.3.26
59
+ rubygems_version: 3.4.10
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Removes redundant Haskell imports.