Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip files with no offenses in the markdown formatter (#10616)
- Loading branch information
Showing
8 changed files
with
101 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
changelog/change_markdown_formatter_to_skip_files_with_no_offenses.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* [#10616](https://github.com/rubocop/rubocop/pull/10616): Markdown formatter: skip files with no offenses. ([@rickselby][]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
spec/fixtures/markdown_formatter/project/app/controllers/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class ApplicationController < ActionController::Base | ||
# Prevent CSRF attacks by raising an exception. | ||
# For APIs, you may want to use :null_session instead. | ||
protect_from_forgery with: :exception | ||
|
||
# “Test encoding issues by using curly quotes” | ||
end |
74 changes: 74 additions & 0 deletions
74
spec/fixtures/markdown_formatter/project/app/controllers/books_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class BooksController < ApplicationController | ||
before_action :set_book, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /books | ||
# GET /books.json | ||
def index | ||
@books = Book.all | ||
end | ||
|
||
# GET /books/1 | ||
# GET /books/1.json | ||
def show | ||
end | ||
|
||
# GET /books/new | ||
def new | ||
@book = Book.new | ||
end | ||
|
||
# GET /books/1/edit | ||
def edit | ||
end | ||
|
||
# POST /books | ||
# POST /books.json | ||
def create | ||
@book = Book.new(book_params) | ||
|
||
respond_to do |format| | ||
if @book.save | ||
format.html { redirect_to @book, notice: 'Book was successfully created.' } # aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
format.json { render :show, status: :created, location: @book } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @book.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /books/1 | ||
# PATCH/PUT /books/1.json | ||
def update | ||
respond_to do |format| | ||
if @book.update(book_params) | ||
format.html { redirect_to @book, notice: 'Book was successfully updated.' } # aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
format.json { render :show, status: :ok, location: @book } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @book.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /books/1 | ||
# DELETE /books/1.json | ||
def destroy | ||
@book.destroy | ||
respond_to do |format| | ||
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' } # aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_book | ||
@book = Book.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the allow list through. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
def book_params | ||
params.require(:book).permit(:name) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Book < ActiveRecord::Base | ||
def someMethod | ||
foo = bar = baz | ||
Regexp.new(/\A<p>(.*)<\/p>\Z/m).match(full_document)[1] rescue full_document | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
spec/fixtures/markdown_formatter/project/app/models/shelf.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
# Book class comment | ||
class Book < ActiveRecord::Base | ||
def some_method | ||
Regexp.new(%r{\A<p>(.*)</p>\Z}m).match(full_document)[1] | ||
rescue StandardError | ||
full_document | ||
end | ||
end |