Skip to content

Commit

Permalink
chore(lint): add satandardrb linter/formatter (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
cassidycodes authored Oct 8, 2024
1 parent e0c8a0d commit 8060168
Show file tree
Hide file tree
Showing 34 changed files with 406 additions and 426 deletions.
31 changes: 12 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,26 @@ on:
- master

jobs:
rubocop:
standard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f
with:
ruby-version: '3.3'
bundler-cache: true

- run: bundle exec rake rubocop

- name: Standard Ruby
uses: standardrb/standard-ruby-action@v1
test:
strategy:
fail-fast: false
matrix:
ruby-version:
- '3.1'
- '3.2'
- '3.3'
- "3.1"
- "3.2"
- "3.3"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- uses: ruby/setup-ruby@2a9a743e19810b9f3c38060637daf594dbd7b37f
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true

- run: bundle exec rake spec
- run: bundle exec rake spec
51 changes: 10 additions & 41 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
AllCops:
TargetRubyVersion: 2.6
NewCops: enable
Exclude:
- 'examples/**/*'
- 'k6/**/*'
- 'gemfiles/**/*'
- 'tmp/**/*'
- 'vendor/**/*'

Metrics/BlockLength:
Exclude:
- 'spec/**/*'

Layout/LineLength:
Exclude:
- 'spec/**/*'

Naming/FileName:
Enabled: false

Style/ClassVars:
Enabled: false

Metrics/AbcSize:
Enabled: false

Metrics/PerceivedComplexity:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/MethodLength:
Enabled: false

Metrics/ClassLength:
Enabled: false

Gemspec/DevelopmentDependencies:
EnforcedStyle: 'gemspec'
require:
- standard
- standard-custom
- standard-performance
- rubocop-performance

inherit_gem:
standard: config/base.yml
standard-custom: config/base.yml
standard-performance: config/base.yml
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in graphql-hive.gemspec
gemspec

group :development do
gem "bundler", "~> 2"
gem "rake", "~> 13"
gem "rspec", "~> 3"
gem "standardrb", "~> 1"
end
40 changes: 28 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
graphql-hive (0.4.2)
graphql-hive (0.4.3)
graphql (>= 2.3, < 3)

GEM
Expand All @@ -14,16 +14,16 @@ GEM
base64
json (2.7.2)
language_server-protocol (3.17.0.3)
parallel (1.25.1)
parser (3.3.3.0)
lint_roller (1.1.0)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
racc (1.8.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
rexml (3.3.1)
strscan
rexml (3.3.8)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
Expand All @@ -37,22 +37,38 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)
rubocop (1.64.1)
rubocop (1.65.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
regexp_parser (>= 2.4, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.31.3)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-performance (1.21.1)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-progressbar (1.13.0)
strscan (3.1.0)
unicode-display_width (2.5.0)
standard (1.40.1)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.65.0)
standard-custom (~> 1.0.0)
standard-performance (~> 1.4)
standard-custom (1.0.2)
lint_roller (~> 1.0)
rubocop (~> 1.50)
standard-performance (1.4.0)
lint_roller (~> 1.1)
rubocop-performance (~> 1.21.0)
standardrb (1.0.1)
standard
unicode-display_width (2.6.0)

PLATFORMS
arm64-darwin-23
Expand All @@ -63,7 +79,7 @@ DEPENDENCIES
graphql-hive!
rake (~> 13)
rspec (~> 3)
rubocop (~> 1)
standardrb (~> 1)

BUNDLED WITH
2.5.15
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

require 'rubocop/rake_task'
require "rubocop/rake_task"
RuboCop::RakeTask.new

task(default: %i[spec rubocop])
14 changes: 7 additions & 7 deletions examples/simple-api/Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'graphql'
gem 'graphql-hive', path: '../../'
gem 'puma'
gem 'rack-contrib'
gem 'sinatra'
gem 'sinatra-contrib'
gem "graphql"
gem "graphql-hive", path: "../../"
gem "puma"
gem "rack-contrib"
gem "sinatra"
gem "sinatra-contrib"
16 changes: 8 additions & 8 deletions examples/simple-api/app.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'sinatra'
require 'sinatra/json'
require 'rack/contrib'
require "sinatra"
require "sinatra/json"
require "rack/contrib"

require_relative 'schema'
require_relative "schema"

# Test query:
#
Expand All @@ -16,14 +16,14 @@
class DemoApp < Sinatra::Base
use Rack::JSONBodyParser

post '/graphql' do
post "/graphql" do
result = Schema.execute(
params['query'],
params["query"],
variables: params[:variables],
operation_name: params[:operationName],
context: {
client_name: 'GraphQL Client',
client_version: '1.0'
client_name: "GraphQL Client",
client_version: "1.0"
}
)
json result
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-api/config.ru
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require './app'
require "./app"
run DemoApp
28 changes: 14 additions & 14 deletions examples/simple-api/schema.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'graphql'
require 'graphql-hive'
require "graphql"
require "graphql-hive"

module Types
class PostType < GraphQL::Schema::Object
description 'A blog post'
description "A blog post"
field :id, ID, null: false
field :title, String, null: false
# fields should be queried in camel-case (this will be `truncatedPreview`)
Expand All @@ -12,29 +12,29 @@ class PostType < GraphQL::Schema::Object
end

class Types::PostInput < GraphQL::Schema::InputObject
description 'Query Post arguments'
description "Query Post arguments"
argument :id, ID, required: true
end

class Types::TestEnum < GraphQL::Schema::Enum
value 'TEST1'
value 'TEST2'
value 'TEST3'
value "TEST1"
value "TEST2"
value "TEST3"
end

class QueryType < GraphQL::Schema::Object
description 'The query root of this schema'
description "The query root of this schema"

# First describe the field signature:
field :post, Types::PostType, 'Find a post by ID' do
field :post, Types::PostType, "Find a post by ID" do
argument :input, [Types::PostInput]
argument :test, Types::TestEnum
end

# Then provide an implementation:
def post(input:, test:)
{ id: 1, title: 'GraphQL Hive with `graphql-ruby`',
truncated_preview: 'Monitor operations, inspect your queries and publish your GraphQL schema with GraphQL Hive' }
{id: 1, title: "GraphQL Hive with `graphql-ruby`",
truncated_preview: "Monitor operations, inspect your queries and publish your GraphQL schema with GraphQL Hive"}
end
end

Expand All @@ -44,9 +44,9 @@ class Schema < GraphQL::Schema
use(
GraphQL::Hive,
buffer_size: 2,
token: 'YOUR_TOKEN',
token: "YOUR_TOKEN",
debug: true,
reporting: { author: 'Charly Poly', commit: '109bb1e748bae21bdfe663c0ffc7e830' },
client_info: proc { |context|{ name: context[:client_name], version: context[:client_version] }}
reporting: {author: "Charly Poly", commit: "109bb1e748bae21bdfe663c0ffc7e830"},
client_info: proc { |context| {name: context[:client_name], version: context[:client_version]} }
)
end
35 changes: 15 additions & 20 deletions graphql-hive.gemspec
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'graphql-hive/version'
require "graphql-hive/version"

Gem::Specification.new do |spec|
spec.name = 'graphql-hive'
spec.version = Graphql::Hive::VERSION
spec.authors = ['Charly POLY']
spec.email = ['[email protected]']
spec.name = "graphql-hive"
spec.version = Graphql::Hive::VERSION
spec.authors = ["Charly POLY"]
spec.email = ["[email protected]"]

spec.summary = '"GraphQL Hive integration for `graphql-ruby`"'
spec.description = '"Monitor operations, inspect your queries and publish your GraphQL schema with GraphQL Hive"'
spec.homepage = 'https://docs.graphql-hive.com/specs/integrations'
spec.license = 'MIT'
spec.summary = '"GraphQL Hive integration for `graphql-ruby`"'
spec.description = '"Monitor operations, inspect your queries and publish your GraphQL schema with GraphQL Hive"'
spec.homepage = "https://docs.graphql-hive.com/specs/integrations"
spec.license = "MIT"

spec.metadata = { 'rubygems_mfa_required' => 'true' }
spec.metadata = {"rubygems_mfa_required" => "true"}

spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")

spec.require_paths = ['lib']
spec.files = Dir.chdir(File.expand_path(__dir__)) do
spec.require_paths = ["lib"]
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
end

spec.add_dependency 'graphql', '>= 2.3', '< 3'

spec.add_development_dependency 'bundler', '~> 2'
spec.add_development_dependency 'rake', '~> 13'
spec.add_development_dependency 'rspec', '~> 3'
spec.add_development_dependency 'rubocop', '~> 1'
spec.add_dependency "graphql", ">= 2.3", "< 3"
end
16 changes: 8 additions & 8 deletions k6/graphql-api/Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source 'https://rubygems.org'
source "https://rubygems.org"

gem 'graphql', '~> 2'
gem 'graphql-hive', path: '../../'
gem 'puma', '~> 6'
gem 'racc'
gem 'rack-contrib', '~> 2'
gem 'sinatra', '~> 2'
gem 'sinatra-contrib'
gem "graphql", "~> 2"
gem "graphql-hive", path: "../../"
gem "puma", "~> 6"
gem "racc"
gem "rack-contrib", "~> 2"
gem "sinatra", "~> 2"
gem "sinatra-contrib"
Loading

0 comments on commit 8060168

Please sign in to comment.