overcommit 0.67.1 → 0.68.0

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: e81508d0f9854d0ad04bb88a192e479efd14d2dcb72520656e96ffbd42d2a10c
4
- data.tar.gz: 58cf91765bfd9b4fc13f287f7d8d0fc5de9abdd5f4306e8c06a6e98b49df005e
3
+ metadata.gz: 57b026be0de6f8992a7959d366a7c131025b1de64e442d5fdbf3e73481501645
4
+ data.tar.gz: 17e3e01c75287dcfac05d6e8b8114db2aa772cd407efed388bd68674714ff46c
5
5
  SHA512:
6
- metadata.gz: 87650f7f66f4f2d1b652154f44a853aa6486e57befbc91c520f05ac28cce74ca291a7cb5681efcde73436f3bbc7bc7fa0c6eceb9fc8f4abeea44de94c54cd7f0
7
- data.tar.gz: e9872666ee60dc587668c17331e476d3287e22a2b2ca3ddf656f9bf863d1c315f208458c2c5c21c0e0d7ae779e1cbd7357ebe5fd361be1812799b7018095257a
6
+ metadata.gz: 6a0f34b82082e8b20eb23c7cb77066d2a2f6135d38b8a700c247f014100c2bd6f4ab6f0e0ff14517e219891eafa54a4d0bf4796604971d91d5125e2435d17e11
7
+ data.tar.gz: a7f96cef415b1722d62f4cede3af1808005c16f892095ea1ff7f420eef00bd448dad778fc699c5e4360dab1f21847cd892375187c2a6ad8ef1d14944573a5d1a
data/config/default.yml CHANGED
@@ -799,6 +799,20 @@ PreCommit:
799
799
  install_command: 'gem install slim_lint'
800
800
  include: '**/*.slim'
801
801
 
802
+ Solargraph:
803
+ enabled: false
804
+ description: 'Typecheck with Solargraph'
805
+ requires_files: true
806
+ required_executable: 'solargraph'
807
+ install_command: 'gem install solargraph'
808
+ flags: ['typecheck', '--level', 'strong']
809
+ include: '**/*.rb'
810
+ exclude:
811
+ - 'spec/**/*.rb'
812
+ - 'test/**/*.rb'
813
+ - 'vendor/**/*.rb'
814
+ - '.bundle/**/*.rb'
815
+
802
816
  Sorbet:
803
817
  enabled: false
804
818
  description: 'Analyze with Sorbet'
@@ -24,7 +24,7 @@ module Overcommit::Hook::PreCommit
24
24
  extract_messages(
25
25
  messages,
26
26
  MESSAGE_REGEX,
27
- lambda { |type| type.to_sym }
27
+ lambda(&:to_sym)
28
28
  )
29
29
  end
30
30
  end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'overcommit'
4
+ require 'overcommit/hook/pre_commit/base'
5
+
6
+ module Overcommit
7
+ module Hook
8
+ module PreCommit
9
+ # Runs `solargraph typecheck` against any modified Ruby files.
10
+ #
11
+ # @see https://github.com/castwide/solargraph
12
+ class Solargraph < Base
13
+ MESSAGE_REGEX = /^\s*(?<file>(?:\w:)?[^:]+):(?<line>\d+) - /.freeze
14
+
15
+ def run
16
+ result = execute(command, args: applicable_files)
17
+ return :pass if result.success?
18
+
19
+ stderr_lines = remove_harmless_glitches(result.stderr)
20
+ violation_lines = result.stdout.split("\n").grep(MESSAGE_REGEX)
21
+ if violation_lines.empty?
22
+ if stderr_lines.empty?
23
+ [:fail, 'Solargraph failed to run']
24
+ else
25
+ # let's feed it stderr so users see the errors
26
+ extract_messages(stderr_lines, MESSAGE_REGEX)
27
+ end
28
+ else
29
+ extract_messages(violation_lines, MESSAGE_REGEX)
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ # @param stderr [String]
36
+ #
37
+ # @return [Array<String>]
38
+ def remove_harmless_glitches(stderr)
39
+ stderr.split("\n").reject do |line|
40
+ line.include?('[WARN]') ||
41
+ line.include?('warning: parser/current is loading') ||
42
+ line.include?('Please see https://github.com/whitequark')
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Overcommit
5
- VERSION = '0.67.1'
5
+ VERSION = '0.68.0'
6
6
  end
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
@@ -42,7 +42,6 @@ if gemfile
42
42
  exit 78 # EX_CONFIG
43
43
  end
44
44
  end
45
- # rubocop:enable Style/RescueModifier
46
45
 
47
46
  begin
48
47
  require 'overcommit'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.67.1
4
+ version: 0.68.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-03-03 00:00:00.000000000 Z
10
+ date: 2025-06-30 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: childprocess
@@ -209,6 +209,7 @@ files:
209
209
  - lib/overcommit/hook/pre_commit/semi_standard.rb
210
210
  - lib/overcommit/hook/pre_commit/shell_check.rb
211
211
  - lib/overcommit/hook/pre_commit/slim_lint.rb
212
+ - lib/overcommit/hook/pre_commit/solargraph.rb
212
213
  - lib/overcommit/hook/pre_commit/sorbet.rb
213
214
  - lib/overcommit/hook/pre_commit/sqlint.rb
214
215
  - lib/overcommit/hook/pre_commit/standard.rb