Skip to content
Merged
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
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ Style/ExponentialNotation:
Style/FormatStringToken:
Enabled: false

Style/FrozenStringLiteralComment:
EnforcedStyle: always_true

Style/GuardClause:
Enabled: false

Expand Down
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ Style/OptionalBooleanParameter:
- 'app/jobs/analyze_change_job.rb'
- 'app/models/application_record.rb'

# Offense count: 67
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: when_needed, always, never
Style/FrozenStringLiteralComment:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ gem 'hiredis'
gem 'sentry-ruby', '~> 5.26.0'
gem 'sentry-rails', '~> 5.26.0'

# We don't make direct use of this; it's really here to suppress a warning about upcoming changes to bundled gems.
gem "pstore", "~> 0.2.0"

# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ GEM
method_source (~> 1.0)
pry-rails (0.3.11)
pry (>= 0.13.0)
pstore (0.2.0)
psych (5.2.6)
date
stringio
Expand Down Expand Up @@ -468,6 +469,7 @@ DEPENDENCIES
pg (~> 1.6)
postmark-rails
pry-rails
pstore (~> 0.2.0)
puma (~> 7.1)
pundit (~> 2.5.2)
rack-brotli
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Admin
class UsersController < ApplicationController
before_action :authenticate_user!
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AdminController < ApplicationController
protect_from_forgery with: :exception

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/annotations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::AnnotationsController < Api::V0::ApiController
include SortingConcern
include BlockedParamsConcern
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/api_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::ApiController < ApplicationController
skip_forgery_protection

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/changes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::ChangesController < Api::V0::ApiController
include SortingConcern
include BlockedParamsConcern
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/diff_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::DiffController < Api::V0::ApiController
def show
ensure_diffable
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/imports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::ImportsController < Api::V0::ApiController
before_action { authorize :api, :import? }

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/maintainers_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::MaintainersController < Api::V0::ApiController
include SortingConcern

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::PagesController < Api::V0::ApiController
include SortingConcern
include BlockedParamsConcern
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/tags_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::TagsController < Api::V0::ApiController
include SortingConcern

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/urls_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::UrlsController < Api::V0::ApiController
before_action(except: [:index, :show]) { authorize(:api, :import?) }

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/api/v0/versions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Api::V0::VersionsController < Api::V0::ApiController
include SortingConcern
include BlockedParamsConcern
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
include Pundit::Authorization
include SameOriginSessionsConcern
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/blocked_params_concern.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Block unauthenticated requests that use certain params with a 403 (Forbidden)
# error. This can be used to prevent abuse of options that may cause expensive
# operations.
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/paging_concern.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module PagingConcern
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/same_origin_sessions_concern.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Make sessions available only to requests from the same host as the server.
#
# This means sessions work for people browsing this site directly, but not for
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/sorting_concern.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SortingConcern
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/healthcheck_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class HealthcheckController < ApplicationController
def index
# Succeed if the app is running, but provide additional
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class HomeController < ApplicationController
def index
render
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Users::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Users::SessionsController < Devise::SessionsController
skip_forgery_protection

Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/jobs/analyze_change_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# NOTE: THIS JOB IS NOT IN ACTIVE USE.
# The use cases it served were better solved by the task-sheets project
# (https://github.com/edgi-govdata-archiving/web-monitoring-task-sheets).
Expand Down
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
2 changes: 2 additions & 0 deletions app/jobs/import_versions_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ImportVersionsJob < ApplicationJob
queue_as :import

Expand Down
2 changes: 2 additions & 0 deletions app/lib/data_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Tools for working with database data. These are mostly used in rake tasks and migrations.
module DataHelpers
class ProgressLogger
Expand Down
2 changes: 2 additions & 0 deletions app/lib/numeric_interval.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class NumericInterval
attr_reader :start, :start_open
attr_reader :end, :end_open
Expand Down
2 changes: 2 additions & 0 deletions app/lib/surt.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'addressable/uri'

# Tools for canonicalizing and formatting URLs according to the Internet
Expand Down
4 changes: 3 additions & 1 deletion app/lib/surt/canonicalize.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'addressable/uri'

module Surt::Canonicalize
Expand Down Expand Up @@ -83,7 +85,7 @@ module Surt::Canonicalize
# test fails if we just use Addressable's standard set. Maybe drop this?
# Also validate against the original Java version:
# https://github.com/iipc/webarchive-commons/blob/5fb641b7ff3c63ade0eb39782fc8b1982ea27330/src/main/java/org/archive/url/BasicURLCanonicalizer.java#L219-L275
URL_SPECIAL_CHARACTERS = '!"$&\'()*+,-./:;<=>?@[\]^_`{|}~'.freeze
URL_SPECIAL_CHARACTERS = '!"$&\'()*+,-./:;<=>?@[\]^_`{|}~'
SAFE_CHARACTERS = "0-9a-zA-Z#{Regexp.escape(URL_SPECIAL_CHARACTERS)}".freeze

# Canonicalize a URL. This is the normal entrypoint to this module.
Expand Down
2 changes: 2 additions & 0 deletions app/lib/surt/format.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Surt::Format
DEFAULT_OPTIONS = {
include_scheme: false,
Expand Down
2 changes: 2 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
Expand Down
2 changes: 2 additions & 0 deletions app/mailers/invitation_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class InvitationMailer < ApplicationMailer
def invitation_email(invitation)
@invitation = invitation
Expand Down
2 changes: 2 additions & 0 deletions app/models/annotation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Annotation < ApplicationRecord
include UuidPrimaryKey

Expand Down
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true

Expand Down
2 changes: 2 additions & 0 deletions app/models/change.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Change < ApplicationRecord
include UuidPrimaryKey

Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/simple_title.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SimpleTitle
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/taggable.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Taggable
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/models/concerns/uuid_primary_key.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module UuidPrimaryKey
extend ActiveSupport::Concern

Expand Down
2 changes: 2 additions & 0 deletions app/models/import.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Import < ApplicationRecord
belongs_to :user
enum :status, [:pending, :processing, :complete]
Expand Down
2 changes: 2 additions & 0 deletions app/models/invitation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Invitation < ApplicationRecord
EXPIRATION_DAYS = 14

Expand Down
2 changes: 2 additions & 0 deletions app/models/maintainer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Maintainer represents an organization that maintains some web pages. It has
# a name and an optional link to a parent maintainer so there can be a
# hierarchical relationship (e.g. an office of a department of an organization)
Expand Down
2 changes: 2 additions & 0 deletions app/models/maintainership.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Maintainership < ApplicationRecord
belongs_to :maintainer, foreign_key: :maintainer_uuid
belongs_to :page, foreign_key: :page_uuid
Expand Down
2 changes: 2 additions & 0 deletions app/models/merged_page.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# MergedPage keeps track of pages that were merged into others so we can
# support old links by redirecting to the page they were merged into.
# - The primary key is the ID of the page that was merged and removed
Expand Down
2 changes: 2 additions & 0 deletions app/models/page.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Page < ApplicationRecord
include UuidPrimaryKey
include Taggable
Expand Down
2 changes: 2 additions & 0 deletions app/models/page_url.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# PageUrl is a critical part of each Page model. Pages do not represent a
# single URL -- pages are often reachable from multiple URLs (sometimes at
# the same time; sometimes because a page moves over time) and different
Expand Down
2 changes: 2 additions & 0 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Tag < ApplicationRecord
include UuidPrimaryKey

Expand Down
2 changes: 2 additions & 0 deletions app/models/tagging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Tagging < ApplicationRecord
belongs_to :taggable, polymorphic: true, foreign_key: :taggable_uuid
belongs_to :tag, inverse_of: :taggings, foreign_key: :tag_uuid
Expand Down
10 changes: 6 additions & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

class User < ApplicationRecord
PERMISSIONS = [
VIEW_PERMISSION = 'view'.freeze,
ANNOTATE_PERMISSION = 'annotate'.freeze,
IMPORT_PERMISSION = 'import'.freeze,
MANAGE_USERS_PERMISSION = 'manage_users'.freeze
VIEW_PERMISSION = 'view',
ANNOTATE_PERMISSION = 'annotate',
IMPORT_PERMISSION = 'import',
MANAGE_USERS_PERMISSION = 'manage_users'
].freeze

PERMISSION_DESCRIPTIONS = {
Expand Down
2 changes: 2 additions & 0 deletions app/models/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Version < ApplicationRecord
include UuidPrimaryKey
include SimpleTitle
Expand Down
2 changes: 2 additions & 0 deletions app/policies/admin_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class AdminPolicy < ApplicationPolicy
def any?
user.can_manage_users?
Expand Down
2 changes: 2 additions & 0 deletions app/policies/api_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApiPolicy < ApplicationPolicy
def view?
Rails.configuration.allow_public_view || (user.present? && user.can_view?)
Expand Down
2 changes: 2 additions & 0 deletions app/policies/application_policy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationPolicy
attr_reader :user, :record

Expand Down
Loading