Skip to content

Add codespell support (config, workflow to detect/not fix) and make it fix some typos #3513

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = .git*,*.pdf,*.svg,locale,vendor,*.lock,*.css,*.min.*,.codespellrc,locales,language_presenter.rb
check-hidden = true
# ignore-regex =
ignore-words-list = ans,rememberable,requestor,reord
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within .codespellrc
---
name: Codespell

on:
push:
branches: [main]
pull_request:
branches: [main]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Metrics/MethodLength:
Max: 20

# mnicholson Oct. 6th 2021
# Default lenght for block is 25 lines, which it would be very restrictive for
# Default length for block is 25 lines, which it would be very restrictive for
# the Rspec views methods. So I'll just exclude some files.
Metrics/BlockLength:
Exclude:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ As Webpacker is no longer maintained by the Rails community, we have replaced it
- Removed `font-awesome-sass` gem and used `@fortawesome/fontawesome-free` npm package
- Issue with `@import 'font-awesome-sprockets';` line in `app/assets/stylesheets/application.scss`. Removed that line after referring to the latest font-awesome install/setup guide which no longer includes it.

With the removal of Webpacker, the Javascript/SASS code is no longer automaticaly compiled when using the `rails server` command. It has been replaced by the `bin/dev` command that launch the rails server and the processes that watch for changes in the SASS and Javascript code.
With the removal of Webpacker, the Javascript/SASS code is no longer automatically compiled when using the `rails server` command. It has been replaced by the `bin/dev` command that launch the rails server and the processes that watch for changes in the SASS and Javascript code.

#### SASS update : removal of the `@import` keyword

Expand Down Expand Up @@ -287,7 +287,7 @@ For more detailed explanation, please refer to this video : https://www.youtube.
- Froze mail gem version [#3254](https://github.com/DMPRoadmap/roadmap/issues/3254)
- Updated the CSV export so that it now includes research outputs
- Updated sans-serif font used in PDF downloads to Roboto since Google API no longer offers Helvetica
- Fixed discrepencies with default/max per_page values for API and UI pagination
- Fixed discrepancies with default/max per_page values for API and UI pagination
- Updated JS that used to call the TinyMCE `setMode()` function so that it now calls `mode.set()` because the former is now deprecated.
- Patched an issue that was causing a template's visibility to change to 'organizationally_visible' when saving on the template details page.
- Fixed an issue with the Rails 6 keyword arguments change that was causing the `paginable_sort_link` to fail
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/blocks/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# CSS Blocks

Blocks refer to reusable units within the CSS files. Where practicable, we should always try to define a general block or UX concept, rather than styling indivudual elements.
Blocks refer to reusable units within the CSS files. Where practicable, we should always try to define a general block or UX concept, rather than styling individual elements.

Example:

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/blocks/_cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
color: $color-secondary-text;
}

// Classes from Boostrap 3 panels (renamed card) - interim solution
// Classes from Bootstrap 3 panels (renamed card) - interim solution
.card-default {
border-color: #ddd;
border-radius: 0rem;
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/blocks/_labels.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import "../../../../node_modules/bootstrap/scss/functions";
@import "../../../../node_modules/bootstrap/scss/variables";

/* label stlying */
/* label styling */
label {
font-weight: 700;
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/base_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def paginate_response(results:)
end

# =========================
# PERMIITTED PARAMS HEPERS
# PERMIITTED PARAMS HELPERS
# =========================
def plan_permitted_params
%i[created title description language ethical_issues_exist
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/conditional_user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module ConditionalUserMailer
#
# recipients - User or Enumerable object or any object that includes Enumerable class
# key - A key (dot notation) whose value is true/false and belongs to
# prefences.email (see dmproadmap.rb initializer)
# preferences.email (see dmproadmap.rb initializer)
#
# Returns Boolean
def deliver_if(key:, recipients: [], &block)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/paginable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def refine_query(scope)

# Can raise ActiveRecord::StatementInvalid (e.g. column does not
# exist, ambiguity on column, etc)
# how we contruct scope depends on whether sort field is in the
# how we construct scope depends on whether sort field is in the
# main table or in a related table
scope_table = scope.klass.name.underscore
parts = @args[:sort_field].partition('.')
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/versionable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module Versionable
private

# Takes in a Template, phase, Section, Question, or Annotaion
# Takes in a Template, phase, Section, Question, or Annotation
# IF the template is published, generates a new template
# finds the passed object in the new template
#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module OrgAdmin
# Controller that handles transfering parent template changes to a customized template
# Controller that handles transferring parent template changes to a customized template
class TemplateCustomizationTransfersController < ApplicationController
include Versionable

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def duplicate
end
# rubocop:enable Metrics/AbcSize

# TODO: This should probablly just be merged with the update route
# TODO: This should probably just be merged with the update route
# POST /plans/:id/visibility
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def visibility
Expand Down Expand Up @@ -433,7 +433,7 @@ def visibility
end
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength

# TODO: This should probablly just be merged with the update route
# TODO: This should probably just be merged with the update route
# POST /plans/:id/set_test
def set_test
plan = Plan.find(params[:id])
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/public_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def template_export
# only export live templates, id passed is family_id
@template = Template.live(params[:id])
# covers authorization for this action.
# Pundit dosent support passing objects into scoped policies
# Pundit doesn't support passing objects into scoped policies
unless PublicPagePolicy.new(current_user, @template).template_export?
msg = 'You are not authorized to export that template'
redirect_to public_templates_path, notice: msg and return
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def do_update_password(current_user, args)
elsif args[:password_confirmation].blank?
message = _('Please enter a password confirmation')
elsif args[:password] != args[:password_confirmation]
message = _('Password and comfirmation must match')
message = _('Password and confirmation must match')
else
successfully_updated = current_user.update_with_password(args)
end
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/answers/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $(() => {
* form with class form-answer. The key represents a question id and the value holds
* the debounced function for a given input, textarea or select. Note, this map is
* populated on demand, i.e. the first time a change is made at a given input, textarea
* or select within the form, a new key-value should be created. Succesive times, the
* or select within the form, a new key-value should be created. Successive times, the
* debounced function should be retrieved instead.
*/
const debounceMap = {};
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/src/answers/rdaMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ $(() => {

function waitAndUpdate() {
if (noWaiting > 0) {
// if we are waiting on api responces, call this function in 1 seccond
// if we are waiting on api responses, call this function in 1 second
setTimeout(waitAndUpdate, 1000);
} else {
// update all the dropdowns/ standards explore box (calling on subject
Expand Down Expand Up @@ -183,7 +183,7 @@ $(() => {
// update the standards display selector
$('.rda_metadata .sub-subject select').change();
} else {
// show the sub-subject incase it was previously hidden
// show the sub-subject in case it was previously hidden
subSubject.closest('div').show();
// update the sub-subject display selector
subSubject.find('option').remove();
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/src/orgAdmin/conditions/updateConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function updateConditions(id) {

if (webhook === false) {
if ($(selectObject).val() === 'add_webhook') { // condition type is webhook
// Retreive 'data-bs-target' for modal and create Jquery element
// Retrieve 'data-bs-target' for modal and create Jquery element
const associatedModal = $(condition.find('.pseudo-webhook-btn').attr('data-bs-target'));
associatedModal.modal('show');
condition.find('.display-if-action-remove').hide();
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function updateConditions(id) {
condition.find('.webhook-replacement').show();
$(condition.find('.webhook-replacement')).on('click', (event) => {
event.preventDefault();
// Retreive 'data-bs-target' for modal and create Jquery element
// Retrieve 'data-bs-target' for modal and create Jquery element
const associatedModal1 = $(condition.find('.pseudo-webhook-btn').attr('data-bs-target'));
associatedModal1.modal('show');
});
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/usage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $(() => {
};

// attach listener to separator select menu
// on change look for "stat" elements and chnage their query param
// on change look for "stat" elements and change their query param
const fieldSep = document.getElementById('csv-field-sep');
if (fieldSep !== null) {
fieldSep.addEventListener('click', (e) => {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/utils/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* <a href="#" data-toggle-direction="hide"><%= _('collapse all') %></a>
* </div>
*
* Your accordion should follow the Boostrap 5.x layout:
* Your accordion should follow the Bootstrap 5.x layout:
* ------------------------------------------------------------
n*
* <div class="accordion" id="accordionDefault">
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/src/utils/sectionUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export const updateSectionProgress = (id, numSecAnswers, numSecQuestions) => {
};

// given a question id find the containing div
// used inconditional questions
// used unconditional questions
export const getQuestionDiv = (id) => $(`#answer-form-${id}`).closest('.question-body');
2 changes: 1 addition & 1 deletion app/javascript/src/utils/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const Tinymce = {
},
/*
Destroy an editor instance whose target element/textarea has HTML id passed. This method
executes tinymce.Editor.destroy (e.g. https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#destroy) for a successfull id found.
executes tinymce.Editor.destroy (e.g. https://www.tinymce.com/docs/api/tinymce/tinymce.editor/#destroy) for a successful id found.
@return undefined
*/
destroyEditorById(id) {
Expand Down
4 changes: 2 additions & 2 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def permissions_change_notification(role, user)
@role = role
@plan_title = @role.plan.title
@user = user
@recepient = @role.user
@recipient = @role.user
@messaging = role_text(@role)
@helpdesk_email = helpdesk_email(org: @user.org)

I18n.with_locale I18n.default_locale do
mail(to: @recepient.email,
mail(to: @recipient.email,
subject: format(_('Changed permissions on a Data Management Plan in %{tool_name}'),
tool_name: tool_name))
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/plan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def settings(key)
# none exists.
#
# qid - The id for the question to find the answer for
# create_if_missing - If true, will genereate a default answer
# create_if_missing - If true, will generate a default answer
# to the question (defaults: true).
#
# Returns Answer
Expand Down
6 changes: 3 additions & 3 deletions app/models/role.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Role < ApplicationRecord
# Return ActiveRecord::Relation
scope :with_access_flags, lambda { |*flags|
bad_flag = flags.detect { |flag| !flag.in?(flag_mapping['access'].keys) }
raise ArgumentError, "Unkown access flag '#{bad_flag}'" if bad_flag
raise ArgumentError, "Unknown access flag '#{bad_flag}'" if bad_flag

access_values = flags.map { |flag| sql_in_for_flag(flag.to_sym, 'access') }
.flatten
Expand Down Expand Up @@ -124,7 +124,7 @@ def deactivate!
# 03 - creator + administrator
# 04 - editor
# 05 - creator + editor
# 06 - administraor + editor
# 06 - administrator + editor
# 07 - creator + editor + administrator
# 08 - commenter
# 09 - creator + commenter
Expand All @@ -140,7 +140,7 @@ def deactivate!
# 19 - creator + administrator + reviewer
# 20 - editor + reviewer
# 21 - creator + editor + reviewer
# 22 - administraor + editor + reviewer
# 22 - administrator + editor + reviewer
# 23 - creator + editor + administrator + reviewer
# 24 - commenter + reviewer
# 25 - creator + commenter + reviewer
Expand Down
2 changes: 1 addition & 1 deletion app/models/section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def deep_copy(**options)
copy
end

# Can't be modified as it was duplicatd over from another Phase.
# Can't be modified as it was duplicated over from another Phase.
def unmodifiable?
!modifiable?
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,17 +450,17 @@ def publishability
unless latest?
error += _('You can not publish a historical version of this template. ')
publishable = false
# all templates have atleast one phase
# all templates have at least one phase
end
if phases.count <= 0
error += _('You can not publish a template without phases. ')
publishable = false
# all phases must have atleast 1 section
# all phases must have at least 1 section
end
unless phases.map { |p| p.sections.count.positive? }.reduce(true) { |fin, val| fin && val }
error += _('You can not publish a template without sections in a phase. ')
publishable = false
# all sections must have atleast one question
# all sections must have at least one question
end
unless sections.map { |s| s.questions.count.positive? }.reduce(true) { |fin, val| fin && val }
error += _('You can not publish a template without questions in a section. ')
Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,15 @@ def identifier_for(scheme)
identifiers.by_scheme_name(scheme, 'User')&.first
end

# Checks if the user is a super admin. If the user has any privelege which requires
# Checks if the user is a super admin. If the user has any privilege which requires
# them to see the super admin page then they are a super admin.
#
# Returns Boolean
def can_super_admin?
can_add_orgs? || can_grant_api_to_orgs? || can_change_org?
end

# Checks if the user is an organisation admin if the user has any privlege which
# Checks if the user is an organisation admin if the user has any privilege which
# requires them to see the org-admin pages then they are an org admin.
#
# Returns Boolean
Expand Down
2 changes: 1 addition & 1 deletion app/policies/api/v1/plans_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PlansPolicy < ApplicationPolicy
# NOTE: @user is either a User or an ApiClient

# A helper method that takes the current client and returns the plans they
# have acess to
# have access to
class Scope
## return the visible plans (via the API) to a given client
# ALL can view: public
Expand Down
2 changes: 1 addition & 1 deletion app/policies/template_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def unpublish?
# - The template which they are modifying belongs to their org
##

# Anyone with an account should be able to get templates for the sepecified research_org + funder
# Anyone with an account should be able to get templates for the specified research_org + funder
# This policy is applicable to the Create Plan page
def template_options?
@user.present?
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/contributor_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def role_symbol_to_string(symbol:)
def role_tooltip(symbol:)
case symbol
when :data_curation
_('Management activities to annotate (produce metadata), scrub data and maintain research data (including software code, where it is necessary for interpreting the data itself) for initial use and later re-use.')
_('Management activities to annotate (produce metadata), scrub data and maintain research data (including software code, where it is necessary for interpreting the data itself) for initial use and later reuse.')
when :investigation
_('Conducting a research and investigation process, specifically performing the experiments, or data/evidence collection.')
when :project_administration
Expand Down
2 changes: 1 addition & 1 deletion app/services/api/v1/auth/jwt/json_web_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Api
module V1
module Auth
module Jwt
# Class to handle encryption/descryption of the JWT
# Class to handle encryption/decryption of the JWT
class JsonWebToken
class << self
def encode(payload:, exp: 24.hours.from_now)
Expand Down
2 changes: 1 addition & 1 deletion app/services/api/v1/conversion_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def yes_no_unknown_to_boolean(value)
false
end

# Converts the context and value into an Identifier with a psuedo
# Converts the context and value into an Identifier with a pseudo
# IdentifierScheme for display in JSON partials. Which will result in:
# { type: 'context', identifier: 'value' }
def to_identifier(context:, value:)
Expand Down
2 changes: 1 addition & 1 deletion app/services/api/v1/deserialization/funding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Api
module V1
module Deserialization
# Logic to deserialize RDA common standard to a Plan funder and grant infor
# Logic to deserialize RDA common standard to a Plan funder and grant info
class Funding
class << self
# Convert the funding information and attach to the Plan
Expand Down
Loading