Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RuboCop related gems #460

Merged
merged 2 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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