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 and resolve lint errors #644

Merged
merged 25 commits into from
Oct 22, 2020

Conversation

tegandbiscuits
Copy link
Contributor

Context

Summary of Changes

Sets up rubocop with rubocop-rspec and rubocop-rails, and resolves warnings/errors that it spits out. Mostly sticking to the default settings for the rules.

Given that these changes were largely cosmetic and to prevent confusion, and that the test suite seems pretty extensive, I don't believe any of these changes will have side effects. For anything that I wasn't sure about fixing, I just added a rubocop:disable comment.

I also added it to the Travis CI script so future pull requests need to pass lint.

Checklist

  • CI Passes
  • Deploys to Heroku on test Correctly (Maintainers will handle)
  • Added Documentation (Service and Code when required)

mi-wood and others added 14 commits April 12, 2020 17:56
* db/seeds.rb: Give restroom entries an edit_id (RefugeRestrooms#567)

Only applies during development and testing
when we use the "db/export.csv" data.

Doesn't affect production, which uses the real data in its db.

* Explain how to run individual tests and access psql (RefugeRestrooms#570)

Also, clarify that there are two containers, web and db,
rather than just one; these can be viewed using
docker ps

* Make filter with "focus" class more readable

* Remove unused li

* Allow dropdown menu text to wrap and fit within the dropdown

Add border bottom to give each menu item more separation

* yarn.lock: Update jquery (RefugeRestrooms#587)

* Dockerfile: Update and streamline steps (RefugeRestrooms#586)

Does effectively the same things as before,
but now in a simpler/faster way.

Some of the changes take inspiration from
@btyy77c's dockerAlpine branch:
https://github.com/btyy77c/refugerestrooms/blob/dockerAlpine/Dockerfile

The PhantomJS install is based on (mostly copy-pasted from)
@nkovacs' phantomjs image from Docker Hub:
https://github.com/nkovacs/selenium-standalone-phantomjs/blob/c5f6bba218472270/Dockerfile#L19-L22

* Dockerfile: Get latest Node.js in a major version (RefugeRestrooms#589)

(Also installs Node.js in /usr/local/
instead of installing Node.js in the root directory.)

With this updated script, we specify just a major version
and the script picks the latest minor/patch version within that.

--

Nodejs.org does most of the work by maintaining the "latest-v[MAJOR]"
folders; We only need to parse the "SHASUMS256.txt" file from there,
and pick the "linux-x64" variant, which works with our Docker setup.

At this point we can use the known directory URL, plus the filename
extracted from "SHASUMS256.txt", and download with curl, or wget, etc.

(e.g. "curl -L https://nodejs.org/dist/latest-v10.x/node-v10.16.0-linux-x64.tar.xz -o nodejs.tar.xz")

--

There is no "latest-LTS" folder or similar, so automatically getting
the latest LTS version would be more difficult.

We could search "nodejs.org/dist/" for folders with
the name "latest-[LETTERS-ONLY-STRING]", which would be the folders
of all the LTS codenames. Among these, the one with
the alphabetically last name is the latest LTS.

This would work at least until around 2040, when they may have
to loop around and re-use some earlier letters (a, b, c, etc.)

* Update Node.js and Ruby dependencies (RefugeRestrooms#590)

* yarn.lock: Update Node.js packages

* Gemfile.lock: Update gems

* Add Bugsnag to readme

To fufill the open source agreement, we have to link to bugsnag now in our readme.

* .travis.yml: Use minimal base image for Travis CI

We do all the setup/build steps inside a Docker container,
so we don't need ruby tools outside of Docker
(on the Travis CI virtual machine instances).

Should save about 20 seconds of Travis CI build time.

--

Inspired by @btyy77c who did this first at their dockerAlpine branch:
  - btyy77c@393cf46

Documentation at Travis re: minimal/generic images:
  - https://docs.travis-ci.com/user/languages/minimal-and-generic/

* docker-compose.yml: Use postgresql:alpine image

This (the Alpine Linux-based postgresql image) is a smaller image
than the debian-based postgresql image,
so it should be marginally faster to download.

Seems like a good idea in general,
to speed up build times (even outside of Travis CI).

Also should save some disk space for developers.

--

Inspired by the general concept of @btyy77c's dockerAlpine branch:
  - https://github.com/btyy77c/refugerestrooms/commits/dockerAlpine

Docker Hub documentation on the alpine vs debian postgres images:
  - https://hub.docker.com/_/postgres#image-variants

* layouts/_footer.html.haml: Remove tumblr link

* stylesheets/.../common: Remove tumblr icon stlye

* en/footer.en.yml: Remove string for tumblr blog

This isn't needed anymore,
since we have removed the tumblr link from the footer.

* removed tumblr from about page (RefugeRestrooms#593)

I noticed we were removing tumblr, here's one more instance

* Create about.fil.yml (RefugeRestrooms#465)

* Filipino Translation devise.fil.yml (RefugeRestrooms#454)

* Create devise.fil.yml

* Update devise.fil.yml

* Update for devise.fil.yml @100% Translation

* Update and rename devise.fil.yml to devise.fl.yml

* Update and rename devise.fl.yml to devise.fil.yml

* 100% completed for restroom.fil.yml file  (RefugeRestrooms#467)

* Create restroom.fil.yml

* Translations for EN to FIL Issue 451 (RefugeRestrooms#556)

Translated files from EN to FIL RefugeRestrooms#451

* config/locales/fil/: Remove tumblr

See RefugeRestrooms#592 and RefugeRestrooms#593

* Updated filipino translations

* switched sass-rails gem (RefugeRestrooms#595)

* switched sass-rails gem (sass-rails --> sassc-rails)

* Changed the word `restroom` to `banyo` to be mroe understandable to most Filipinos

* Fixed some unnoticed words that needed some changes in translation

* additional translation changes

* config/application.rb: Add 'fil' locale (Filipino)

Enables translations as merged in RefugeRestrooms#596

* .travis.yml: Set "dist" to "trusty" (RefugeRestrooms#600)

Should allow our CI tests to pass
while we investigate test failures on xenial and newer.

* production.rb: Fix i18n.fallbacks deprecation warn

* config/application.rb: Add Tagalog (:tl) locale

* production.rb: I18n fallbacks for :tl --> :fil

We don't maintain separate translations for
"Tagalog" and Filipino, since they are arguably the same language.

However, Firefox only allows users to set "Tagalog" as preferred,
and Chrome only allows users to set "Filipino" as preferred.

To support both browsers, we must support both the "Tagalog"
and the "Filipino" locales.

(These locales use the "tl" and "fil" locale codes, respectively.)

* config/application.rb: Set default locale to "en"

* package.json: Update swagger to master with patch

* yarn.lock: Commit updated (indirect) dependencies

* yarn.lock: Update all packages

* Gemfile[.lock]: Update devise, simple_form

* yarn.lock: Upgrade swagger-ui's dependencies

* Ruby: Upgrade from 2.5.3 to 2.5.7

* Dockerfile: Work around an issue with phantomjs

When running the tests, cliver tries to check that PhantomJS's version
is within a certain range, by running "phantomjs --version".

The "phantomjs --version" command fails for some reason
on the new ruby:2.5.7-slim Docker base image.

Perhaps because the new Docker image is based on Debian 10 "Buster,"
whereas the old Docker image was based on Debian 9 "Stretch"?

This commit's workaround allows "phantomjs --version" to work again.

* Fix Travis tests failing on distributions other than trusty (RefugeRestrooms#606)

* Revert ".travis.yml: Set "dist" to "trusty" (RefugeRestrooms#600)"

This reverts commit ac8f6ab.

Doing this to run tests on Travis to investigate why they
aren't passing.

* Explicitly require locations.rb in rspec.rb

Tentative fix for tests not passing in xenial but passing in trusty.
This might be because different distributions load files in a
different order. In xenial, `rspec.rb` might get loaded before
`locations.rb`, making `Locations` uninitialized. Explicit require
fixes this.

* Dockerfile: Upgrade Node from v10.x to v12.x (RefugeRestrooms#603)

Node 12 "Erbium" is the newest Long Term Service release.

We should either pin a version of Node in our package.json file,
or stay on the latest LTS version of Node;

Heroku will use the latest LTS version of Node 
in production if we don't have any versions pinned in our package.json

* Webpack Upgrade (RefugeRestrooms#607)

* Updated webpacker gem

* Upgraded yarn packages

* Ran webpack:install process.  Working without rails-erb-loader

* Added rails-erb-loader to webpack

* Fixed include PgSearch warning

* Added .dockerignore

* PR RefugeRestrooms#607: Minor tweaks/cleanup

- Adjust Gemfile[.lock] to specify webpacker within the 4.x series,
  rather than any version 4.0 or greater.

- Delete some duplicate entries in the .gitignore file

* CONTRIBUTING.md: Remove the reference to "Cmd + C"

The "Cmd + C" keyboard shortcut is for copying text,
not quitting programs in the terminal.

The proper way to quit programs in the terminal
under macOS is "Ctrl + C", the same as Linux.

Referring to "Cmd + C" here was based on
a mistaken assumption that "Ctrl" on Windows or Linux
always gets translated to "Cmd" on macOS.

(In fact, some uses of "Ctrl" on Windows/Linux
are preserved as-is on macOS. It's a mixed bag.)

Deleting the reference to "Ctrl + C", to make the guidance clearer.

* db/schema.rb: Commit with underscores in date

The date gets underscores added automatically
when running migrations on the database.

Committing with the underscores so the change isn't flagged by git
when no code has been changed.

* restrooms_spec.rb: Fix a test (RefugeRestrooms#608)

Background:

The Mission Creek Cafe in San Francisco has been closed for some time.

Google Maps API now resolves "Mission Creek Cafe"
to a coffee shop in Washington state.

Washington is too far away from our stub restroom entries;
No stub restrooms are located near Washington,
so no restroom results are shown on our results page for this search.

The test expects to see a stub restroom entry on the reults page,
but does not see it, and so the test fails.

---

Fix:

search the Maps API for "San Francisco," not "Mission Creek Cafe"

(This returns a lat/long associated with San Francisco not Washington)

* Update some dependencies, fix some deprecation warnings (RefugeRestrooms#609)

* Gemfile[.lock]: Update simplecov

Fixes a deprecation warning

* restrooms_spec.rb: Use 'successful' not 'success'

Rspec's `be_success` and `.success?` are deprecated.

Rspec's `be_successful` and `.successful?`
are the non-deprecated versions of this check.

(This fixes the associated deprecation warning)

* Gemfile.lock: Bump some dependencies

Upgraded loofah, puma, rack, and rack-cors,
plus their dependencies.

* Tweak CSS a bit for narrow screens (e.g. mobile phones) (RefugeRestrooms#610)

* CSS: Add some styles for narrow screens

For screen widths ~340px or narrower.

(Such a narrow screen is found, for example, on the original iPhone
through to the iPhone 5S and iPhone SE.)

- Makes the "+" icon on the "Add A Restroom" button
  appear in a more correct-looking position.

- Fixes the overlap of the "Refuge Restrooms" text
  with the "hamburger" drop-down menu button in the header/nav section.

- Adds a class via the haml source (.nav-column)
  to make applying one of the style rules easier.

* CSS: No double-padding on nested `.container`s

Eliminate double-padding in cases of
an [element].container immediately inside another [element].container.

(Doing this only directly under the header div, just to be conservative.)

The 15px + 15px = 30px of padding on both sides
seemed unintentionally wide. Also, I think this looks nicer.
Helps with the tight fit on mobile devices, too.

(Should affect the header/nav on all pages other than the home page,
aka the splash page, due to the way the pages are coded.)

* CSS: Center logo and brand name on narrow screens (RefugeRestrooms#611)

* _mobile.scss: Lower logo/brand on narrow screens

Adjust the CSS "top" property to set the logo and "brand name"
("Refuge Restrooms") slightly lower within the navbar on narrow
screens.

This is to adjust for the navbar being responsively taller
on narrower screens. "767px screen width" happens to be the responsive
threshold for that height change for the navbar.

* _mobile.scss: Move 342px rules, adjust whitespace

Moved the "max 342px" rules to the bottom, so all screen-width-related
style rules are in descending order of the sizes that they apply to.
(For consistency).

Adjusted the use of newlines in this stylesheet to be more consitent.

* Update docker config (RefugeRestrooms#616)

* Dockerfile: Use better PhantomJS URL

GitHub's CDN is more reliable than BitBucket's.

(This is the URL we originally used as of PR RefugeRestrooms#435,
which was the initial implementation of our Docker setup.)

* docker-compose.yml: Add password for PostgreSQL db

This is in response to a recent change in the PostgreSQL Docker image.

Either the database must be configured to not check passwords, i.e.
`POSTGRESQL_HOST_AUTH_METHOD=trust`, or a password must now be set.

For explanation and context, see:

- docker-library/postgres#658
- docker-library/postgres#681
- docker-library/postgres#580
- https://discuss.circleci.com/t/postgresql-image-password-not-specified-issue/34555

* Ruby: Update from 2.5.7 to 2.5.8 (RefugeRestrooms#618)

* Update Node.JS and Ruby Dependencies (RefugeRestrooms#617)

* Gemfile[.lock]: Update rails to 5.2.4.2

Also update its dependencies, as required.

* Gemfile[.lock]: Update grape and grape-swagger

Also update their dependencies, as needed.

* Gemfile[.lock]: Update activeadmin

* Gemfile: Pin sprockets to "< 4"

The 4.x major version upgrade requires some configuration changes.

Pinning keeps the app from breaking when doing `bundle update`.

* Gemfile.lock: Update all packages

* yarn.lock: Update all packages

* Implement Google's reCAPTCHA (RefugeRestrooms#566)

* Add server reCAPTCHA verification for contacts

Added a temporary secret key for testing in .env, which is loaded by
the dotenv gem. In production, just put another key in the Heroku
env variable settings.

* Add reCAPTCHA to contacts submission page

* Enable browser form validation by default

This gets form input validated on the client side, which gives faster
feedback to the user, without the need for a custom solution. This
feature is supported in all modern browsers.

* Add reCAPTCHA to restrooms page

* Make stub for reCAPTCHA verification during tests

Co-authored-by: Mikena Wood <mi-wood@users.noreply.github.com>

Co-authored-by: DeeDeeG <DeeDeeG@users.noreply.github.com>
Co-authored-by: Kai Middleton <kai.middleton@hingehealth.com>
Co-authored-by: hkly <hannah.k.yiu@gmail.com>
Co-authored-by: Teagan <tkwidmer@gmail.com>
Co-authored-by: Joe Wadcan <joe.wadcan@github.com>
Co-authored-by: vinzruzell <35182720+vinzruzell@users.noreply.github.com>
Co-authored-by: hnarasaki <hnarasaki@indeed.com>
Co-authored-by: Bryan Mark Fajutag <fbryanmark@gmail.com>
Co-authored-by: Emily Ring <emily_ring@ymail.com>
Co-authored-by: Jason Chen <kbtpodifo@gmail.com>
* Update dependencies for May 2020 (RefugeRestrooms#622)

- dependencies: Update puma and jquery
- dependencies: Bump Kaminari and Rails
* Add reference to docker troubleshooting wiki in `CONTRIBUTING.md` (RefugeRestrooms#625)

  - Add reference to docker troubleshooting wiki in contributing documentation

  - Update CONTRIBUTING.md

* Add listeners to close infowindow when another is opened (RefugeRestrooms#628)

* CONTRIBUTING.md: Docker for Windows requirements

-  Docker Desktop for Window requires Windows 10 64-bit,
   "Professional" or "Enterprise" editions.

* Update dependencies June 2020 (RefugeRestrooms#629)

  - dependencies: Bump geocoder, websocket-extensions

  - Gemfile.lock: Update rack to 2.2.3

Co-authored-by: Pierce Bala <65255475+piercebb@users.noreply.github.com>
* README.md: Update Slack invite link (RefugeRestrooms#631)

  This one apparently will NOT expire.

* yarn.lock: Update elliptic and lodash (RefugeRestrooms#633)
This will effect every file and have potential side effects, so I'm
going to start with this turned off.
- rubocop-rspec

AllCops:
NewCops: enable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this setting if an update to rubocop adds a new rule it'll automatically be enabled, which could cause the test suite to fail linting.

I could remove this setting so it just logs that a rule has been added, but in my experience new rules don't usually cause issues and not automatically enabling causes more work to have to manually enable them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good as-is. I think your reasoning sounds good; I can agree with that approach.

Comment on lines +37 to +38
Style/StringLiterals:
Enabled: false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the rule for checking that strings use single quotes or double quotes. Right now there's a mixture, so this should probably be enabled for consistency. I turned it off so this pull request touches less things, but I could enable it now or later if desired.

The default is single quotes unless it'll make a difference, but I could put it for double.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default sounds good to me.

I think double-quote usage should be reserved for when it means something, so as to draw attention to whatever advanced/interpolation stuff is going on in our strings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Pull Request is already rather large, so I personally think it would be okay to include the quotation mark normalization here as well. If it is committed in a neat way here, that would make it easy to review.

However, maybe saving it for a separate Pull Request is good for this reason: We have "squash pull requests" enabled at this repository. So this entire Pull Request is destined to become one commit on the develop branch. Perhaps we should want the quotation mark normalization done separately so it stays a separate commit on develop branch.

Copy link
Contributor

@DeeDeeG DeeDeeG Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, thanks for the thoughtful approach to enabling this linter. Anticipating some of the pitfalls, however minor, increases my confidence with adding the linter and is making the experience better of adding it to the repository. It's personally my first time using Rubocop, so that's great.

@@ -1,12 +1,11 @@
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone unaware, creating a hash like { foo: 'bar' } and { :foo => 'bar' } is the same (=> is only needed if you don't want the key to be a symbol).

app/models/contact.rb Show resolved Hide resolved

validates :name, :street, :city, :state, presence: true

geocoded_by :full_address
after_validation :perform_geocoding

reverse_geocoded_by :latitude, :longitude do |obj, results|
if geo = results.first
if geo == results.first
Copy link
Contributor Author

@tegandbiscuits tegandbiscuits Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure if the == was the desired effect for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I think this is meant to check if the assignment works (thereby checking that results.first exists and isn't undefined/null or what-have-you), and then use the gio object only if that's the case (only if it has become a copy of results.first).

I don't believe geo is defined anywhere else in the project, so the == likely makes reverse_geocoded_by fail to update the obj (object) passed to it. Sorry for the verbose explanation, but I'm explaining it to myself as I go as well. (Said so before, but I haven't edited the Ruby code much -- I have read much of it though several times, just not 100% understanding as I'm so-so with Ruby).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the intent or correctness, I presume this was copy-pasted and lightly modified from the geocoder gem's README.md:

https://github.com/alexreisner/geocoder/tree/v1.6.4#custom-result-handling

Comment on lines +15 to +16
# TODO: this assertion doesn't seem to ever run
expect(restroom.created_at).to be >= previous_record.created_at if previous_record.present?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expect didn't seem to run before these changes.

Also if you're open to it, I wouldn't mind adding something like expect(json).not_to be_empty above line 12 in order to prevent false positives if this loop never runs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding expect(json).not_to be_empty sounds good. Thanks for noticing this!

Is the # TODO comment still accurate? Or if this expect() is running now, then I suppose the comment can/should be deleted.

@@ -55,8 +54,8 @@

let(:json) { JSON.parse(response.body) }

context 'a list of unisex restrooms' do
before :each do
context 'when requesting a list of unisex restrooms' do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the wording because of the RSpec/ContextWording rule (this rule is also why I changed some context blocks to describe since it seemed more semantic).

If I'm very off base with the wording I can just disable this rule.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the more semantic wording! I like it when the error messages read like natural language and make sense as sentences.

And so, I was actually meaning to go back and review these and just make sure the new wordings still captured the intent or explain what the test is for in an accurate way. Wanted to help ensure that could happen. I'll see how involved this all gets... Could be some work, but it seems worth it to get it right now for benefit of use later on down the line.

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 9, 2020

Thanks for all the work, and the thoughtful comments. I'm finding those helpful.

cc @tkwidmer and @mi-wood I have been copying you both on a lot of things lately, but you are both more expert at Ruby than I am. Your review(s) for this PR would be appreciated.

@tegandbiscuits I am still committed to reviewing this if I don't hear back from either of them. I'm not sure what their schedules look like right now.

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 12, 2020

I'm going to call this accepted, for hacktoberfest purposes. I should get a chance some time to really review the changes and possibly revert some small things and/or tweak the settings. But this is passing tests, and it mostly looks good.

Thank you!

@DeeDeeG DeeDeeG added Hacktoberfest These are issues or pull requests related to Hacktoberfest (https://hacktoberfest.digitalocean.com/) Ready for Review labels Oct 12, 2020
@tegandbiscuits
Copy link
Contributor Author

@DeeDeeG I'll revert back the = tonight since that could cause problems.

Thanks!

tegandbiscuits and others added 2 commits October 12, 2020 18:28
The condition was actually supposed to be `if geo = results.first`,
because that's not always obvious the intention and fails lint, I'm just
doing a truthy check for it which should be the same.
@tegandbiscuits
Copy link
Contributor Author

Good catch about the typo!

results is defined by the parameter to the block, and it looks like the conditional is checking that it's not empty (which it presumably could be if no location was found).

I tried it out with

results = []
puts 'hello' if x = results.first

results = ['something']
puts 'hello' if x = results.first

mi-wood
mi-wood previously approved these changes Oct 14, 2020
Copy link
Member

@mi-wood mi-wood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This generally lgtm. Thanks! I think we had houndci for linting at some point and it was causing a bit too much noise, but never followed up to readd something else.

Only thing I'd add, is that we should loop back to the docs so that people know they can autofix linting and don't spend time trying to manually fix all the coding style.

app/models/contact.rb Show resolved Hide resolved
@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 17, 2020

Only thing I'd add, is that we should loop back to the docs so that people know they can autofix linting and don't spend time trying to manually fix all the coding style.

As long as there's an easy command to run, I'd be happy to cook up some wording for CONTRIBUTING.md about this.

Seems like it's rubocop --auto-correct (per a documentation page I found: https://docs.rubocop.org/rubocop/0.93/usage/auto_correct.html#safe-auto-correct).

@tegandbiscuits
Copy link
Contributor Author

@DeeDeeG sorry it took a couple days to reply. I added a bit of docs to CONTRIBUTING.md for linting. Let me know if you want me to change it (or you could change it yourself if you'd rather).

Undid all the changes to the Gemfile and Gemfile.lock, and readded
rubocop. This seems to work, so hopfully CI passes.
Comment on lines +84 to +97
### 7 Linting Code
Ruby code is linted with [rubocop](https://docs.rubocop.org/).

If you want to lint your code before pushing it, you can run:
```
docker-compose run web rubocop
```

Some lint issues can be resolved automatically by running:
```
docker-compose run web rubocop --auto-correct
```

### 8 Shut down the Docker Container:
Copy link
Contributor

@DeeDeeG DeeDeeG Oct 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks for adding documentation. Awesome. ❤️

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 19, 2020

@tegandbiscuits no worries on response time. As you can see, we all have stuff going on and I also take some time to respond...

I want to make sure I finish up the review process here and get this merged before any other Pull Requests land. The intent is not to make you have to lint other people's work. Sorry about that.

Here's what I will do: I will put up a Heroku instance (hosted instance of the web app) and do a manual walk-through of all the features. If everything works, I think we can go ahead and merge this.

Thanks for all your work. If you're looking to complete your five pull requests for Hacktoberfest still (and I suppose even if you're not), I would welcome the quotation mark normalization as a second pull request. That one might be simpler, but a lot of work had been put in already on this main pull request, and I think that counts as at least two typical pull requests' worth of work. Regardless of points and t-shirts and whatnot (regarding the Hacktoberfest event), this PR took a lot of time and work and I appreciate it.

DeeDeeG
DeeDeeG previously approved these changes Oct 20, 2020
Copy link
Contributor

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything works in manual testing.

Planning to merge this tomorrow.

(Thanks again!)

@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 21, 2020

Hi again,

There's some very small changes I would like to suggest relating to the merge conflicts and how they were resolved.

Essentially, I would revert any changes in Gemfile.lock and yarn.lock from the "merge master"/"merge develop" commits onward.

Tip: how to fix on the command-line (click to expand)
  • You can do this on the command-line with git restore --source=706a669 Gemfile.lock yarn.lock
    • 706a669 is the commit in this pull request just before the merges. The above command restores the files to the state from that commit.
  • If you have git older than 2.23, the git restore command isn't available.
    • You can do this command instead: git checkout 706a669 -- Gemfile.lock yarn.lock

And I noticed there is a duplicated bit of code in spec/support/rspec.rb:

    recaptcha_response = { 'success' => true }
    stub_request(:post, 'https://www.google.com/recaptcha/api/siteverify')
      .to_return(status: 200, body: recaptcha_response.to_json,
                 headers: { 'Content-Type' => 'application/json' })

I would:

  • Delete this duplicate bit of code
    • The block of code apparently becomes shorter, so the comment # rubocop:disable Metrics/BlockLength isn't needed anymore, and can be removed.
    • The corresponding # rubocop:enable Metrics/BlockLength isn't needed.

If you want to address this yourself, I can leave it for you. I also have a copy of this on my machine with the changes, which I could upload to your branch if you don't mind. Once that's resolved, I'll be happy to merge this. As always, thank you for this contribution.

Best Regards,

- DeeDeeG

@tegandbiscuits
Copy link
Contributor Author

@DeeDeeG it’d probably be faster if you could do it. Though I could do it this weekend if it’d be longer than that.

Also re-enable a "block length" rubocop check,
as the block is apparently short enough to pass again.
@DeeDeeG
Copy link
Contributor

DeeDeeG commented Oct 22, 2020

A funny thing happened... Rubocop has been around since roughly 2013, judging by their CHANGELOG.md... but they made a stable 1.0.0 release just yesterday! What timing!

https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md

I suppose it would be a good idea to upgrade to Rubocop 1.0 soon. For now, this pull request is fine using Rubocop 0.92, and will be merged as-is. There are some other pending pull requests that would be good to merge as soon as this one is merged, so Rubocop 1.0 can wait.

@DeeDeeG DeeDeeG merged commit 2535377 into RefugeRestrooms:develop Oct 22, 2020
@DeeDeeG DeeDeeG mentioned this pull request Oct 31, 2020
5 tasks
DeeDeeG added a commit that referenced this pull request Nov 1, 2020
* Finish Upgrading Webpacker to v5 (#637)
  - Gemfile[.lock]: Update webpacker to 5.2.1
  - Webpacker: Update config files
      Ran "rails webpacker:install" and committed the changes.

      In "config/webpacker.yml,"
      kept the ".js.erb" entry under "extensions:"
      so that "app/javascript/packs/lib/maps.js.erb" is included.

      In "config/webpack/environment.js,"
      kept jQuery and rails-erb-loader configs,
      as we are still using these.
  - JS dependencies: Upgrade webpack-dev-server
      Commit the changes from running `rails webpacker:install`,
      but using a caret "^" semver range for "@rails/webpacker",
      rather than an exact version.

      (So that we get updates in the 5.x series)


* Update dependencies for September 2020 (#636)
  - dependencies: Remove `swagger` node module
      We don't actually use this.

      Also removes 200 sub-dependencies,
      and makes our yarn.lock file about 1270 lines shorter!
  - yarn.lock: Upgrade bootstrap to 4.5.2
      (Was at version 4.4.1)
  - dependencies: Resolve node-fetch to ^2.6.1
  - yarn.lock: Upgrade "selfsigned" and "node-forge"
  - Gemfile[.lock]: Update Rails and dependencies
      rails was 5.2.4.3, now it's version 5.2.4.4


* Keeping filters state on pagination (#638)
  - Keeping filters state on pagination
  - Fix Code Climates complaints.
  - Fixed active issue on ada filter buttons
  - Fixed undefined function problem when run rspec.


* Add rubocop and resolve lint errors (#644)
  - Initialize rubocop
  - Run rubocop with --fix
  - Don't require magic comment
      This will affect every file and have potential side effects, so I'm
      going to start with this turned off.
  - Resolve lint errors in `app`
  - RSpec linting
  - Resolve remaining
  - Fix wrong change
  - Singleton method for verify
  - New lint rules
  - Add rubocop to travis config
  - Correct docker compose command
  - Check for geo
      The condition was actually supposed to be `if geo = results.first`,
      because that's not always obvious the intention and fails lint, I'm just
      doing a truthy check for it which should be the same.
  - Fix typo
  - Add contributing docs for rubocop


* Applying ADA filters for the Map view of search. (#651)
  - Applying ADA filters for the Map view of search.
  - Changed comment for polyfill URLSearchParams
  - Fixed bug of map marker content not showing.


* Add a standard EditorConfig configuration for every contributor to follow (#649)


* Enhancement/i18n thread safe (#647)
  - Provide a way to respond requests without thread-safe issues
      As rails docs says https://guides.rubyonrails.org/i18n.html#managing-the-locale-across-requests
      When we use 'I18n.locale =' the current locale could leak into following requests
      this is a standard and recommended way to deal with it :)
  - Create a shared_example to test I18n locale switching
  - Update spec/controllers/pages_controller_spec.rb


* Upgrade puma to latest version 5.x (#641)


* yarn.lock: Update "http-proxy" to v1.18.1 (fe195d7)


Co-authored-by: Lucas <torres.giorgio@gmail.com>
Co-authored-by: Tegan Rauh <3896310+tegandbiscuits@users.noreply.github.com>
Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
continuous integration developer-oriented Hacktoberfest These are issues or pull requests related to Hacktoberfest (https://hacktoberfest.digitalocean.com/)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup linting
3 participants