Browse Source

rubocop linter ok

main
pvincent 1 year ago
parent
commit
cae5492c19
  1. 2
      .rubocop.yml
  2. 6
      .vscode/extensions.json
  3. 45
      Gemfile
  4. 57
      Gemfile.lock
  5. 6
      app/controllers/application_controller.rb
  6. 13
      app/controllers/main_controller.rb
  7. 4
      app/views/main/home.html.erb
  8. 6
      test/controllers/main_controller_test.rb

2
.rubocop.yml

@ -0,0 +1,2 @@
Style/FrozenStringLiteralComment:
Enabled: false

6
.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"
]
}

45
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

57
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

6
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

13
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

4
app/views/main/home.html.erb

@ -1,8 +1,8 @@
<div>
<h1 class="text-4xl font-bold">HOME</h1>
<h2 class="text-2xl bg-gray-400">
<div class="text-2xl bg-gray-400">
this is a welcome message.
</h2>
</div>
<div class="italic text-2xl">
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.
</div>

6
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

Loading…
Cancel
Save