1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00

Lint: Style/FrozenStringLiteralComment

This commit is contained in:
Jared Beck 2017-12-10 23:05:11 -05:00
parent 49397aca6f
commit cfbf7a647c
166 changed files with 328 additions and 9 deletions

View file

@ -12,13 +12,6 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Max: 9 # Goal: 7
# Switching to frozen strings internally would be fine, but if any of those
# frozen strings cross our public API, that would be a breaking change.
# Let's wait until we drop support for ruby 2.2 before doing this. If we freeze
# before dropping 2.2, the comment could be misleading.
Style/FrozenStringLiteralComment:
Enabled: false
RSpec/InstanceVariable:
Exclude:
- spec/paper_trail/associations_spec.rb

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Specify here only version constraints that differ from
# `paper_trail.gemspec`.
#

View file

@ -9,6 +9,7 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
- Drop support for ruby 2.2, [whose EoL is the end of March,
2018](https://www.ruby-lang.org/en/news/2017/09/14/ruby-2-2-8-released/)
- Assume that all strings returned by PaperTrail are frozen.
- Removed deprecated `Version#originator`, use `#paper_trail_originator`
- Using paper_trail.on_destroy(:after) with ActiveRecord's
belongs_to_required_by_default will produce an error instead of a warning.

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
source "https://rubygems.org"
gemspec

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "bundler"
Bundler::GemHelper.install_tasks

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Use this template to report PaperTrail bugs.
# Please include only the minimum code necessary to reproduce your issue.
require "bundler/inline"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rails/generators"
require "rails/generators/active_record"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support"
require "request_store"
require "paper_trail/cleaner"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/type_serializers/postgres_array_serializer"
module PaperTrail
@ -7,7 +9,7 @@ module PaperTrail
# replaces certain default Active Record serializers
# with custom PaperTrail ones.
module AttributeSerializerFactory
AR_PG_ARRAY_CLASS = "ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array".freeze
AR_PG_ARRAY_CLASS = "ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array"
def self.for(klass, attr)
active_record_serializer = klass.type_for_attribute(attr)

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/attribute_serializers/attribute_serializer_factory"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/attribute_serializers/cast_attribute_serializer"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/attribute_serializers/cast_attribute_serializer"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
# Utilities for deleting version records.
module Cleaner

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "singleton"
require "paper_trail/serializers/yaml"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This file only needs to be loaded if the gem is being used outside of Rails,
# since otherwise the model(s) will get loaded in via the `Rails::Engine`.
require "paper_trail/frameworks/active_record/models/paper_trail/version_association"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/version_concern"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/version_association_concern"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# before hook for Cucumber
Before do
PaperTrail.enabled = false

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
require "paper_trail/frameworks/rails/controller"
require "paper_trail/frameworks/rails/engine"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Rails
# Extensions to rails controllers. Provides convenient ways to pass certain

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Rails
# See http://guides.rubyonrails.org/engines.html

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "rspec/core"
require "rspec/matchers"
require "paper_trail/frameworks/rspec/helpers"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module RSpec
module Helpers

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext/object" # provides the `try` method
require "paper_trail/attribute_serializers/object_attribute"
require "paper_trail/attribute_serializers/object_changes_attribute"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/core_ext"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Queries
module Versions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Queries
module Versions

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
# Represents the history of a single record.
# @api private

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
# Represents the "paper trail" for a single record.
class RecordTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "paper_trail/attribute_serializers/object_attribute"
require "paper_trail/reifiers/belongs_to"
require "paper_trail/reifiers/has_and_belongs_to_many"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Reifiers
# Reify a single `belongs_to` association of `model`.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Reifiers
# Reify a single HABTM association of `model`.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Reifiers
# Reify a single, direct (not `through`) `has_many` association of `model`.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Reifiers
# Reify a single HMT association of `model`.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module Reifiers
# Reify a single `has_one` association of `model`.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/json"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "yaml"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
module TypeSerializers
# Provides an alternative method of serialization

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/concern"
module PaperTrail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "active_support/concern"
require "paper_trail/attribute_serializers/object_changes_attribute"
require "paper_trail/queries/versions/where_object"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PaperTrail
# The version number of the paper_trail gem. Not to be confused with
# `PaperTrail::Version`. Ruby constants are case-sensitive, apparently,

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "paper_trail/version_number"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe ArticlesController, type: :controller do

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "spec_helper"
RSpec.describe WidgetsController, type: :controller, versioning: true do

View file

@ -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.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base
protect_from_forgery

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ArticlesController < ApplicationController
def create
@article = Article.create article_params

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class TestController < ActionController::Base
def user_for_paper_trail
Thread.current.object_id

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class WidgetsController < ApplicationController
def paper_trail_enabled_for_controller
request.user_agent != "Disable User-Agent"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Animal < ActiveRecord::Base
has_paper_trail
self.inheritance_column = "species"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Demonstrates the `only` and `ignore` attributes, among other things.
class Article < ActiveRecord::Base
has_paper_trail(

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Authorship < ActiveRecord::Base
belongs_to :book
belongs_to :author, class_name: "Person"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class BarHabtm < ActiveRecord::Base
has_and_belongs_to_many :foo_habtms
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Book < ActiveRecord::Base
has_many :authorships, dependent: :destroy
has_many :authors, through: :authorships

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Boolit < ActiveRecord::Base
default_scope { where(scoped: true) }
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CallbackModifier < ActiveRecord::Base
has_paper_trail on: []

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Car < Vehicle
has_paper_trail
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
class Cat < Animal
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Chapter < ActiveRecord::Base
has_many :sections, dependent: :destroy
has_many :paragraphs, through: :sections

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Citation < ActiveRecord::Base
belongs_to :quotation

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require "securerandom"
class CustomPrimaryKeyRecord < ActiveRecord::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Customer < ActiveRecord::Base
has_many :orders, dependent: :destroy
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Demonstrates a "custom versions association name". Instead of the assication
# being named `versions`, it will be named `paper_trail_versions`.
class Document < ActiveRecord::Base

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
class Dog < Animal
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# to demonstrate a has_through association that does not have paper_trail enabled
class Editor < ActiveRecord::Base
has_many :editorships, dependent: :destroy

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Editorship < ActiveRecord::Base
belongs_to :book
belongs_to :editor

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Elephant < Animal
paper_trail.disable
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Family
class Family < ActiveRecord::Base
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Family
class FamilyLine < ActiveRecord::Base
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Fluxor < ActiveRecord::Base
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
belongs_to :widget, optional: true

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class FooHabtm < ActiveRecord::Base
has_and_belongs_to_many :bar_habtms
accepts_nested_attributes_for :bar_habtms

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
class FooWidget < Widget
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Fruit < ActiveRecord::Base
if ENV["DB"] == "postgres" || JsonVersion.table_exists?
has_paper_trail class_name: "JsonVersion"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Gadget < ActiveRecord::Base
has_paper_trail ignore: :brand
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module Kitchen
class Banana < ActiveRecord::Base
has_paper_trail class_name: "Kitchen::BananaVersion"

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# The `legacy_widgets` table has a `version` column that would conflict with our
# `version` method. It is configured to define a method named `custom_version`
# instead.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LineItem < ActiveRecord::Base
belongs_to :order, dependent: :destroy
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This model does not record versions when updated.
class NotOnUpdate < ActiveRecord::Base
has_paper_trail on: %i[create destroy]

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module On
class Create < ActiveRecord::Base
self.table_name = :on_create

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module On
class Destroy < ActiveRecord::Base
self.table_name = :on_destroy

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module On
class EmptyArray < ActiveRecord::Base
self.table_name = :on_empty_array

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module On
class Update < ActiveRecord::Base
self.table_name = :on_update

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Order < ActiveRecord::Base
belongs_to :customer
has_many :line_items

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Paragraph < ActiveRecord::Base
belongs_to :section

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Person < ActiveRecord::Base
has_many :authorships, foreign_key: :author_id, dependent: :destroy
has_many :books, through: :authorships

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Post < ActiveRecord::Base
has_paper_trail class_name: "PostVersion"
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# This model tests ActiveRecord::Enum, which was added in AR 4.1
# http://edgeguides.rubyonrails.org/4_1_release_notes.html#active-record-enums
class PostWithStatus < ActiveRecord::Base

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Quotation < ActiveRecord::Base
belongs_to :chapter
has_many :citations, dependent: :destroy

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Section < ActiveRecord::Base
belongs_to :chapter
has_many :paragraphs, dependent: :destroy

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Skipper < ActiveRecord::Base
has_paper_trail ignore: [:created_at], skip: [:another_timestamp]
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module OverrideSongAttributesTheRails4Way
def attributes
if name

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Thing < ActiveRecord::Base
has_paper_trail save_changes: false
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
# Demonstrates the `if` and `unless` configuration options.
class Translation < ActiveRecord::Base
# Has a `type` column, but it's not used for STI.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Truck < Vehicle
# This STI child class specifically does not call `has_paper_trail`.
# Of the sub-classes of `Vehicle`, only `Car` is versioned.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class PostgresUser < ActiveRecord::Base
has_paper_trail
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Vehicle < ActiveRecord::Base
# This STI parent class specifically does not call `has_paper_trail`.
# Of its sub-classes, only `Car` is versioned.

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Whatchamajigger < ActiveRecord::Base
has_paper_trail

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class Widget < ActiveRecord::Base
EXCLUDED_NAME = "Biglet".freeze
EXCLUDED_NAME = "Biglet"
has_paper_trail
has_one :wotsit
has_many(:fluxors, -> { order(:name) })

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Wotsit < ActiveRecord::Base
has_paper_trail

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class CustomPrimaryKeyRecordVersion < PaperTrail::Version
self.table_name = "custom_primary_key_record_versions"
end

Some files were not shown because too many files have changed in this diff Show more