Skip to content

Commit

Permalink
Add RuboCop related gems (#460)
Browse files Browse the repository at this point in the history
* Add rubocop-ast type

* Add rbs file for rubocop gem
  • Loading branch information
pocke authored Oct 28, 2023
1 parent ce906ea commit 7746ed6
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 0 deletions.
22 changes: 22 additions & 0 deletions gems/rubocop-ast/1.30/_scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting.
set -eou pipefail
# Internal Field Separator - Linux shell variable
IFS=$'\n\t'
# Print shell input lines
set -v

# Set RBS_DIR variable to change directory to execute type checks using `steep check`
RBS_DIR=$(cd $(dirname $0)/..; pwd)
# Set REPO_DIR variable to validate RBS files added to the corresponding folder
REPO_DIR=$(cd $(dirname $0)/../../..; pwd)
# Validate RBS files, using the bundler environment present
bundle exec rbs --repo $REPO_DIR -r rubocop-ast:1.30 -r parser -r ast validate --silent

cd ${RBS_DIR}/_test
# Run type checks
bundle exec steep check

$(git rev-parse --show-toplevel)/bin/check-untyped-call.rb
$(git rev-parse --show-toplevel)/bin/check-manifest-yaml.rb
13 changes: 13 additions & 0 deletions gems/rubocop-ast/1.30/_test/Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
D = Steep::Diagnostic

target :test do
check "."
signature "."

repo_path "../../../"
library "rubocop-ast"
library 'parser'
library 'ast'

configure_code_diagnostics(D::Ruby.all_error)
end
4 changes: 4 additions & 0 deletions gems/rubocop-ast/1.30/_test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write Ruby code to test the RBS.
# It is type checked by `steep check` command.

require "rubocop-ast"
15 changes: 15 additions & 0 deletions gems/rubocop-ast/1.30/rubocop-ast.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module RuboCop
module AST
class ProcessedSource
def raw_source: () -> String
def buffer: () -> Parser::Source::Buffer
def comments: () -> Array[Parser::Source::Comment]
end

module NodePattern
module Macros
def def_node_matcher: (Symbol, String) -> void
end
end
end
end
22 changes: 22 additions & 0 deletions gems/rubocop/1.57/_scripts/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

# Exit command with non-zero status code, Output logs of every command executed, Treat unset variables as an error when substituting.
set -eou pipefail
# Internal Field Separator - Linux shell variable
IFS=$'\n\t'
# Print shell input lines
set -v

# Set RBS_DIR variable to change directory to execute type checks using `steep check`
RBS_DIR=$(cd $(dirname $0)/..; pwd)
# Set REPO_DIR variable to validate RBS files added to the corresponding folder
REPO_DIR=$(cd $(dirname $0)/../../..; pwd)
# Validate RBS files, using the bundler environment present
bundle exec rbs --repo $REPO_DIR -r rubocop:1.57 -r rubocop-ast -r parser -r ast validate --silent

cd ${RBS_DIR}/_test
# Run type checks
bundle exec steep check

$(git rev-parse --show-toplevel)/bin/check-untyped-call.rb
$(git rev-parse --show-toplevel)/bin/check-manifest-yaml.rb
14 changes: 14 additions & 0 deletions gems/rubocop/1.57/_test/Steepfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
D = Steep::Diagnostic

target :test do
check "."
signature "."

repo_path "../../../"
library "rubocop"
library "rubocop-ast"
library 'parser'
library 'ast'

configure_code_diagnostics(D::Ruby.all_error)
end
4 changes: 4 additions & 0 deletions gems/rubocop/1.57/_test/test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Write Ruby code to test the RBS.
# It is type checked by `steep check` command.

require "rubocop"
26 changes: 26 additions & 0 deletions gems/rubocop/1.57/rubocop.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module RuboCop
class ConfigLoader
def self.debug?: () -> boolish
def self.merge_with_default: (Config, String) -> Config
end

class Config
def initialize: (Hash[untyped, untyped], String) -> void
end

module Cop
class Base
extend AST::NodePattern::Macros

def add_offense: (untyped node, ?message: String) -> void
def cop_config: () -> Hash[String, untyped]
def processed_source: () -> AST::ProcessedSource
end

module RangeHelp
def source_range: (Parser::Source::Buffer source_buffer, Integer line_number, Integer column, ?Integer length) -> Parser::Source::Range
end
end

class ProcessedSource = AST::ProcessedSource
end

0 comments on commit 7746ed6

Please sign in to comment.