profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/pirj/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Phil Pirozhkov pirj Russia, Saint-Petersburg https://fili.pp.ru/ Seasoned software engineer focusing on Ruby and Rails, with past experience with Java and other major platforms.

pirj/dotfiles 15

my humble dotfiles

pirj/gollum-slack 5

Seamless GitHub wiki and Slack integration

pirj/awesome-timesavers 4

Time savers

pirj/descenancy-roguelike 2

Rogulike written with LiveScript (like Coffee) just for fun

pirj/distributed-shelf-example 2

Example web application using dshelf gem and https://distributedshelf.com storage

pirj/distributed-shelf 1

heroku addon support gem. able to store files transparently in remote storage. works with existing codebase with no changes required

pirj/distributed-shelf-example-rails 1

Example Rails web application using dshelf gem and https://distributedshelf.com storage

pirj/facestat 1

Facebook group statistics

issue commentrubocop/rubocop

Style/StringLiterals is missing quoted quotes

I would expect no corrections and no offence for mixed case. No offence with both \" and string interpolation, e.g. "hello \" #{world} \"". Maybe some other cases, too.

pirj

comment created time in 14 hours

issue commentrubocop/rubocop-rspec

RSpec/ExampleWording autocorrect clobbers string

Let's imagine we've marked the cop as unsafe for autocorrection. Now, you would have to fix all the offences that the cop autocorrected for you, manually.

Please keep in mind that most of us are not aware of the -A/--auto-correct-all option, as rubocop --help doesn't display it.

I understand your frustration. However, apart from the support for the initial investigation and further guidance, you're most likely the only volunteer to fix this bug.

ccutrer

comment created time in 16 hours

startedpmq20/ruby-packer

started time in 17 hours

startedavmnu-sng/rspec-tracer

started time in 17 hours

issue commentrubocop/rubocop-rspec

RSpec/ExampleWording autocorrect clobbers string

codebase with many many engineers working on it for many many years. Rubocop being enforced

Familiar situation.

I would suggest to start with resolving the issue with strings first, and moving to rubocop-rspec after. However, unfortunately enough, Style/StringLiteral doesn't handle this. Filed a ticket https://github.com/rubocop/rubocop/issues/10120

I'm actually on the fence if we should really handle the case you've reported. What do you think?

ccutrer

comment created time in 17 hours

issue openedrubocop/rubocop

Style/StringLiterals is missing quoted quotes

No offences for

'hello \'world\'' # for EnforcedStyle: single_quotes
"hello \"world\"" # for EnforcedStyle: double_quotes

According to https://rubystyle.guide/#consistent-string-literals-single-quote, it's bad. It should be written as

"hello 'world'"
'hello "world"'

instead.

Describe the solution you'd like

Extend Style/StringLiterals to flag this.

created time in 18 hours

issue commentrubocop/rubocop-rspec

RSpec/ExampleWording autocorrect clobbers string

It goes beyond my understanding how things work.

A simple fix would probably be to replace node.value here with something like node.loc.expression.source and strip quotes from it. node.loc.expression.source returns "'should do \\' something'", while node.value/node.str_content is "should do ' something".

Ended up with node.value.include?("'") ? node.loc.expression.source[1..-2] : node.value. This fixes your case and the spec is still green. However, if you'll go with this fix, I strongly suggest to check the modified cop against https://github.com/pirj/real-world-rspec

Just a side note that this specific style is not recommended https://rubystyle.guide/#consistent-string-literals-single-quote

ccutrer

comment created time in 20 hours

startedcharmbracelet/glow

started time in a day

startedellisonleao/glow.nvim

started time in a day

issue commentankane/strong_migrations

[Idea] Renaming a table with a temporary view when using Postgres

It turns out that renaming columns can be done without renaming the table. The approach is the same:

  1. rename the table
  2. create a view with both the old and the new name
  3. deploy the code that exclusively uses the new name
  4. drop the view
  5. rename the table and rename the column

Sanity check:

# CREATE TABLE aaa (foo integer, bar integer);
# INSERT INTO aaa (foo, bar) VALUES (3,4);
# select * from aaa;
 foo | bar
-----+-----
   3 |   4
(1 row)

# CREATE VIEW ccc AS
  SELECT foo, foo AS boo, bar, bar AS zar FROM aaa;

# INSERT INTO ccc (boo, zar) VALUES (5,6);
# SELECT * FROM ccc;
 foo | boo | bar | zar
-----+-----+-----+-----
   3 |   3 |   4 |   4
   5 |   5 |   6 |   6
(2 rows)

Am I missing something?

pirj

comment created time in 2 days

pull request commentqmk/qmk_firmware

gBoards GergoPlex

Thank you, @germ, @btannous, @manna-harbour, dear maintainers, and early testers @YorickPeterse, @stjoni and @caksoylar for this to happen! 🎉

pirj

comment created time in 3 days

Pull request review commentrubocop/rubocop-rspec

Bump version to 2.5.0

  ## Master (Unreleased) +## 2.5.0 (2021-09-21)+ * Declare autocorrect as unsafe for `ExpectChange`. ([@francois-ferrandis][]) * Fix each example for `RSpec/HookArgument`. ([@lokhi][]) * Exclude unrelated Rails directories from `RSpec/DescribeClass`. ([@MothOnMars][])

Should we change VersionChanged for DescribeClass from 2.4.1 to 2.5.0 in config/default.yml?

Darhazer

comment created time in 3 days

PullRequestReviewEvent
PullRequestReviewEvent

issue commentalexrabarts/iso_country_codes

Kosovo is now a country.

Is it a good moment to reconsider this?

Among the G20 countries, eleven have recognized Kosovo's independence: Australia, Canada, France, Germany, Italy, Japan, South Korea, Saudi Arabia, Turkey, the United Kingdom and the United States. Eight, however, have not: Argentina, Brazil, China, India, Indonesia, Mexico, Russia and South Africa.

EOengineer

comment created time in 3 days

startedbrunofacca/zen-rails-base-app

started time in 5 days

startedrails/cssbundling-rails

started time in 5 days

startedrails/jsbundling-rails

started time in 5 days

startedrails/importmap-rails

started time in 5 days

issue openedrubocop/rails-style-guide

Use more specific predicates instead of vague `blank?` and `present?`

If puzzles me what the type of the object is when I read something like:

user = find_user
return if user.blank?

or

results = find_matches
suggest(results) if results.present?

Usually, it's [Array, nil] or [Model, nil], and usage of present?/blank? is superfluous.

Array/Hash/NilClass/TrueClass/FalseClass/String and an arbitrary Object define those methods, disguising the exact object type. blank? and present? in the Rails Guides

I'd suggest:

  1. using .nil? or an implicit check when it's only important if it's nil or not:
return if user.nil?
# or
return unless user
  1. using any?/empty?/none? when distinguishing between an empty and non-empty Array/Hash

  2. for ActiveRecord::Relation, see https://github.com/rubocop/rails-style-guide/issues/232#issuecomment-425848425 3.1 using any? over present? 3.2 using empty?/none? over blank?

  3. stop using blank?/present? for booleans

String's blank?/present? are a special case, a string with whitespace only is blank? but not empty?.

cc @marcandre

created time in 6 days

issue commentrspec/rspec-rails

Rspec/Rails System Test Error - no superclass method `after_teardown'

Would you please to open a PR with a failing spec? It should be a good start.

hmistry

comment created time in 6 days

issue openedankane/strong_migrations

[Idea] Renaming a table with a temporary view when using Postgres

The currently suggested approach to rename a table is quite complicated:

Deployment 1:

  • Create a new table
  • Write to both tables
  • Backfill data from the old table to new table Deployment 2:
  • Move reads from the old table to the new table Deployment 3:
  • Stop writing to the old table
  • Drop the old table

What do you think of a different approach: Deployment 1:

  • Create a view with the new name
  • Start reading and writing to the new "table" Deployment 2:
  • Drop the view
  • Rename the table

or even: Deployment 1:

  • Rename the table
  • Create a view for the old name
  • Start reading and writing to the new "table" Deployment 2:
  • Drop the view

This most probably won't work equally fine with MySQL/MariaDB (due to the implicit commit for RENAME TABLE).

https://www.postgresql.org/docs/9.3/sql-createview.html:

Simple views are automatically updatable: the system will allow INSERT, UPDATE and DELETE statements to be used on the view in the same way as on a regular table.

On a side note, this could probably be used for renaming columns along with the table rename. Old table would accept reads/writes for old column name, the new table - for old names. To qualify as a simple view, column names don't have to have the same names:

All columns in the view's select list must be simple references to columns of the underlying relation.

    # select * from users;
    (0 rows)
    # create view losers as select * from users;
    # insert into losers (full_name, email) values ('abc', 'abc@example.com');
    # create view losers2 as select *, full_name as name, email as email_address from users;
    # insert into losers2 (name, email_address) values ('cde', 'cde@example.com');
    # select * from users;
      id  | full_name |      email
    ------+-----------+-----------------
     4002 | abc       | abc@example.com
     4003 | cde       | cde@example.com
    (2 rows)

created time in 6 days

delete branch rspec/rspec-rails

delete branch : remove-incompatible-color-flag

delete time in 6 days

push eventrspec/rspec-rails

Phil Pirozhkov

commit sha 6a34d628f031660331016996e5fbc719fc963b00

Remove incompatible --color CLI option The option was removed in RSpec 4, see https://github.com/rspec/rspec-core/pull/2864 Follow-up to https://github.com/rspec/rspec-rails/pull/2458

view details

push time in 6 days

PR merged rspec/rspec-rails

Remove incompatible --color CLI option

The option was removed in RSpec 4, see https://github.com/rspec/rspec-core/pull/2864 Follow-up to https://github.com/rspec/rspec-rails/pull/2458

+0 -1

1 comment

1 changed file

pirj

pr closed time in 6 days

pull request commentrspec/rspec-rails

Remove incompatible --color CLI option

Merging, as there's no external behaviour change, it only affects our builds. To my best knowledge, --color is a no-op, as color_mode is :automatic by default ("the output will be in color if the output is a TTY").

pirj

comment created time in 6 days

PR opened rspec/rspec-rails

Remove incompatible --color CLI option

The option was removed in RSpec 4, see https://github.com/rspec/rspec-core/pull/2864 Follow-up to https://github.com/rspec/rspec-rails/pull/2458

+0 -1

0 comment

1 changed file

pr created time in 6 days

create barnchrspec/rspec-rails

branch : remove-incompatible-color-flag

created branch time in 6 days

Pull request review commentrspec/rspec-rails

Respect RSpec `default_path` for generators

 Feature: Generator spec                 invoke  rspec                 create    spec/generator/my_generators_generator_spec.rb           """++    Scenario: Use custom generator with customized `default-path`+        Given a file named ".rspec" with:+          """+          --default-path behaviour+          """+        And I run `bundle exec rails generate generator my_generator`+        Then the features should pass+        Then the output should contain:+          """+                create  lib/generators/my_generator+                create  lib/generators/my_generator/my_generator_generator.rb+                create  lib/generators/my_generator/USAGE+                create  lib/generators/my_generator/templates+                invoke  rspec+                create    behaviour/generator/my_generators_generator_spec.rb+          """

Sounds reasonable to fix separately. I recall there were a couple of problems with the structure of those features breaking the table of contents etc.

vivekmiyani

comment created time in 6 days

PullRequestReviewEvent