From cae5492c197fbd07c5f886e7d1c6db1a2ca731d4 Mon Sep 17 00:00:00 2001 From: pvincent Date: Fri, 2 Jun 2023 11:53:39 +0400 Subject: [PATCH] rubocop linter ok --- .rubocop.yml | 2 + .vscode/extensions.json | 6 ++- Gemfile | 45 +++++++++--------- Gemfile.lock | 57 +++++++++++++++++++++++ app/controllers/application_controller.rb | 6 ++- app/controllers/main_controller.rb | 13 ++++-- app/views/main/home.html.erb | 4 +- test/controllers/main_controller_test.rb | 6 +-- 8 files changed, 106 insertions(+), 33 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..c4e4390 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,2 @@ +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5213159..f07a1ea 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,7 +4,9 @@ "bung87.rails", "aliariff.vscode-erb-beautify", "yzhang.markdown-all-in-one", - "arturock.gitstash", - "bradlc.vscode-tailwindcss" + "bradlc.vscode-tailwindcss", + "castwide.solargraph", + "aki77.rails-db-schema", + "formulahendry.auto-rename-tag" ] } \ No newline at end of file diff --git a/Gemfile b/Gemfile index 788ee30..1ab7de5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,34 +1,34 @@ -source "https://rubygems.org" +source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.4" +ruby '3.1.4' # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.0.5" +gem 'rails', '~> 7.0.5' # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" +gem 'sprockets-rails' # Use sqlite3 as the database for Active Record -gem "sqlite3", "~> 1.4" +gem 'sqlite3', '~> 1.4' # Use the Puma web server [https://github.com/puma/puma] -gem "puma", "~> 5.0" +gem 'puma', '~> 5.0' # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] -gem "importmap-rails" +gem 'importmap-rails' # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] -gem "turbo-rails" +gem 'turbo-rails' # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] -gem "stimulus-rails" +gem 'stimulus-rails' # Use Tailwind CSS [https://github.com/rails/tailwindcss-rails] -gem "tailwindcss-rails" +gem 'tailwindcss-rails' # Build JSON APIs with ease [https://github.com/rails/jbuilder] -gem "jbuilder" +gem 'jbuilder' # Use Redis adapter to run Action Cable in production # gem "redis", "~> 4.0" @@ -40,14 +40,14 @@ gem "jbuilder" # gem "bcrypt", "~> 3.1.7" # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] +gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby] # Reduces boot times through caching; required in config/boot.rb -gem "bootsnap", require: false +gem 'bootsnap', require: false # Semantic logger for colorized output logging -gem "amazing_print" -gem "rails_semantic_logger" +gem 'amazing_print' +gem 'rails_semantic_logger' # Use Sass to process CSS # gem "sassc-rails" @@ -57,24 +57,27 @@ gem "rails_semantic_logger" group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri mingw x64_mingw ] + gem 'debug', platforms: %i[mri mingw x64_mingw] end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] - gem "web-console" + gem 'web-console' # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] # gem "rack-mini-profiler" # Speed up commands on slow machines / big apps [https://github.com/rails/spring] # gem "spring" - gem "rails_live_reload" + gem 'rails_live_reload' + gem 'rubocop' + gem 'rubocop-rails' + gem 'solargraph' end group :test do # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] - gem "capybara" - gem "selenium-webdriver" - gem "webdrivers" + gem 'capybara' + gem 'selenium-webdriver' + gem 'webdrivers' end diff --git a/Gemfile.lock b/Gemfile.lock index 4814df6..aae966f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -69,6 +69,9 @@ GEM addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) amazing_print (1.5.0) + ast (2.4.2) + backport (1.2.0) + benchmark (0.2.1) bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) @@ -88,6 +91,8 @@ GEM debug (1.8.0) irb (>= 1.5.0) reline (>= 0.3.1) + diff-lcs (1.5.0) + e2mmap (0.1.0) erubi (1.12.0) ffi (1.15.5) globalid (1.1.0) @@ -100,9 +105,15 @@ GEM io-console (0.6.0) irb (1.6.4) reline (>= 0.3.0) + jaro_winkler (1.5.6) jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) + json (2.6.3) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -132,6 +143,9 @@ GEM nio4r (2.5.9) nokogiri (1.15.2-x86_64-linux) racc (~> 1.4) + parallel (1.23.0) + parser (3.2.2.1) + ast (~> 2.4.1) public_suffix (5.0.1) puma (5.6.5) nio4r (~> 2.0) @@ -175,14 +189,35 @@ GEM rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) + rbs (2.8.4) regexp_parser (2.8.0) reline (0.3.4) io-console (~> 0.5) + reverse_markdown (2.1.1) + nokogiri rexml (3.2.5) + rubocop (1.51.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.2.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-rails (2.19.1) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + ruby-progressbar (1.13.0) rubyzip (2.3.2) selenium-webdriver (4.9.1) rexml (~> 3.2, >= 3.2.5) @@ -190,6 +225,22 @@ GEM websocket (~> 1.0) semantic_logger (4.13.0) concurrent-ruby (~> 1.0) + solargraph (0.49.0) + backport (~> 1.2) + benchmark + bundler (~> 2.0) + diff-lcs (~> 1.4) + e2mmap + jaro_winkler (~> 1.5) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + parser (~> 3.0) + rbs (~> 2.0) + reverse_markdown (~> 2.0) + rubocop (~> 1.38) + thor (~> 1.0) + tilt (~> 2.0) + yard (~> 0.9, >= 0.9.24) sprockets (4.2.0) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -203,6 +254,7 @@ GEM tailwindcss-rails (2.0.29-x86_64-linux) railties (>= 6.0.0) thor (1.2.2) + tilt (2.1.0) timeout (0.3.2) turbo-rails (1.4.0) actionpack (>= 6.0.0) @@ -210,6 +262,7 @@ GEM railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -225,6 +278,7 @@ GEM websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + yard (0.9.34) zeitwerk (2.6.8) PLATFORMS @@ -241,7 +295,10 @@ DEPENDENCIES rails (~> 7.0.5) rails_live_reload rails_semantic_logger + rubocop + rubocop-rails selenium-webdriver + solargraph sprockets-rails sqlite3 (~> 1.4) stimulus-rails diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e0f9ee7..e3035d3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,6 @@ +# frozen_string_literal: true + +# Base Application class ApplicationController < ActionController::Base MAX_DURATION_TO_COMPLETE_IN_SECONDS = 3 @@ -8,7 +11,8 @@ class ApplicationController < ActionController::Base ensure duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start if duration > MAX_DURATION_TO_COMPLETE_IN_SECONDS - logger.warn("processing took too long to complete, please review your code as asynchronous job!", duration: duration * 1_000) + logger.warn('processing took too long to complete, please review your code as asynchronous job!', + duration: duration * 1_000) end end end diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 0607a46..2559666 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -1,18 +1,23 @@ +# MainController for basic routes class MainController < ApplicationController def home - logger.info "efficient logging for dark theme" + logger.info 'efficient logging for dark theme' end def about - logger.debug "some debugging info" + logger.debug 'some debugging info' - logger.info "relevant information" + logger.info 'relevant information' logger.info "multiline\nline2\nline3" - logger.warn "a warning" + logger.warn 'a warning' # logger.error "an error" # raise "this is an error" # sleep 3 end + + def mymethod + puts 'hello world' + end end diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb index 1862271..be65b21 100644 --- a/app/views/main/home.html.erb +++ b/app/views/main/home.html.erb @@ -1,8 +1,8 @@

HOME

-

+
this is a welcome message. -

+
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur provident dolor quod laboriosam facere quas, excepturi quasi consequuntur quo pariatur recusandae, eaque doloremque voluptas, a commodi officia ducimus animi incidunt.
diff --git a/test/controllers/main_controller_test.rb b/test/controllers/main_controller_test.rb index 0a327aa..cfed456 100644 --- a/test/controllers/main_controller_test.rb +++ b/test/controllers/main_controller_test.rb @@ -1,12 +1,12 @@ -require "test_helper" +require 'test_helper' class MainControllerTest < ActionDispatch::IntegrationTest - test "should get home" do + test 'should get home' do get main_home_url assert_response :success end - test "should get about" do + test 'should get about' do get main_about_url assert_response :success end