Commit Graph

8 Commits

Author SHA1 Message Date
Cody Cutrer b903214f1a rubocop: default pre-commit hook to auto-correct-all
since we're not enabling _any_ auto-correct if there are still existing
violations, it seems easier to enable unsafe autocorrects for new code,
when you're most likely to know how to fix it. instead of getting
frustrated and wondering why gergich is complaining about something that
should have been auto-corrected

Change-Id: Ic81316c790820e2d32a1b1826c79ccaa77d1d6ad
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/278081
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-11-12 20:40:28 +00:00
Evan Battaglia f10f379d9f Fix pre-commit hook
/bin/sh has apparently different syntax for [. I get this error (on
Linux).
hooks/pre-commit: 7: [: /home/evan/dev/canvas-lms: unexpected operator

Change-Id: I6f84881cab4ab3b2e1834457f5afa9954e9e203e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274839
Reviewed-by: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
2021-09-30 17:10:33 +00:00
Cody Cutrer 9c9059c8c4 don't run eslint for plugins
but do run rlint (correctly) for plugins

Change-Id: I6728c3e5ce28196caa91ca6d3425097b88e067f6
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274421
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Jacob Burroughs <jburroughs@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-27 18:36:34 +00:00
Cody Cutrer 55c298c037 rubocop: script/rlint -a implies --heavy
since auto-correct always does the entire file, don't make it possible
to correct something _and_ filter out that it was corrected just cause
the current patchset didn't touch it

Change-Id: I7b37bfa89f85b66520db922b7214462f7445eafe
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274314
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-24 02:30:34 +00:00
Cody Cutrer bac7328a6e rubocop: run enforced config in heavy mode on jenkins
Change-Id: I42c9a8e6ab8cdd303c35e0d8d9756c783a653c69
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/274038
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-21 20:41:02 +00:00
Cody Cutrer e9d63396ff rubocop: split configuration
* remove spurious .rubocop.yml override files
 * split the configuration into an enforced and optional
 * run both configurations in jenkins (may result in some duplicate
   comments at different levels)
 * auto-correct the enforced configuration in the pre-commit hook
 * fix comments for Gemfile.d and the root dir; enforced configuration
   is only applied to that directory for now

Change-Id: I8da21073d74e19138b1b580d66c7aae6465348d4
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/273898
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
2021-09-21 16:02:22 +00:00
Brent Burgoyne b9174e5f76 fix pre-commit hook with unfixable eslint error
test plan:
- have a local yarn install
- add an unfixable lint error (unused var) to a file in the prettier
  whitelist
- try to commit the file
- it should not try to run in docker after the lint error

Change-Id: If1fcfc6693be26c6f6fdddb8cfa4c54a73512ebe
Reviewed-on: https://gerrit.instructure.com/173469
Reviewed-by: Clay Diffrient <cdiffrient@instructure.com>
QA-Review: Clay Diffrient <cdiffrient@instructure.com>
Product-Review: Clay Diffrient <cdiffrient@instructure.com>
Tested-by: Jenkins
2018-11-27 23:28:12 +00:00
Clay Diffrient 93a6d18046 Add precommit hook for auto fixing files
This only affects javascript files and only affects things
from the prettier whitelist

This will run slowly if you don't have node_modules installed
locally (e.g., in Docker), but it will gladly attempt to
run things in Docker for you.

This adds a new githook_installer image that will install
the githook whenever a docker-compose up happens in the
repo.  It will also install the hook whenever a `yarn`
occurs locally (as a postinstall hook).

This commit should also not fail things.  For example
having unused variables is an ESLint error, but it isn't
autofixable.  It will log the error, but will otherwise
continue.  However, it will make this pretty with prettier
as well as fix any other autofixable ESLint errors.

closes CORE-2118

Test Plan:
  - Run `yarn`
  - Add some semicolons to something from the whitelist
  - git add that file
  - git commit and it will strip semicolons
  - In a dockerized Canvas:
     - docker-compose up
     - Add semicolons to a file
     - git add that file
     - git commit, it will take forever (~60s)
     - It should have stripped out semicolons

Change-Id: Id9198aa008808e898f29acb9ed64dd14ff843222
Reviewed-on: https://gerrit.instructure.com/171510
Tested-by: Jenkins
Reviewed-by: Brent Burgoyne <bburgoyne@instructure.com>
QA-Review: Brent Burgoyne <bburgoyne@instructure.com>
Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
2018-11-27 21:07:31 +00:00