chore: lint Ruby files with Rubocop (#2435)

* fix: set up Ruby before linting in Github Actions
* chore: separate linting from fixing

Before we commit we want to fix as much as possible, but when we're checking a
pull request we're not going to commit anything so we want to know about all
the problems, including the fixable ones.
This commit is contained in:
Ken-ichi
2024-11-18 21:27:20 -08:00
committed by GitHub
parent e461cce32b
commit e1bc1626d9
8 changed files with 53 additions and 13 deletions

View File

@@ -45,6 +45,12 @@ jobs:
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
# Need this for pre-commit linting of Ruby
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Sync with Crowdin
uses: crowdin/github-action@v2
with:

View File

@@ -12,7 +12,7 @@ concurrency:
jobs:
test:
name: Run Tests
name: Run tests
runs-on: ubuntu-latest
steps:
- name: Check out Git repository
@@ -30,12 +30,21 @@ jobs:
path: node_modules
key: node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install Dependencies
- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm install
- run: npm run lint
- run: npm test
# Need this for linting Ruby
- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Lint
run: npm run lint
- name: Test
run: npm test
notify:
name: Notify Slack

View File

@@ -14,7 +14,7 @@ else
fi
# Run lint and flow
npm run lint
npm run lint:fix
# Generate translations from strings.ftl
npm run translate

View File

@@ -6,10 +6,11 @@ ruby ">= 2.6.10"
# Cocoapods 1.15 introduced a bug which break the build. We will remove the upper
# bound in the template on Cocoapods with next React Native release.
gem "cocoapods", ">= 1.13", "< 1.15"
gem "activesupport", ">= 6.1.7.5", "< 7.1.0"
gem "cocoapods", ">= 1.13", "< 1.15"
gem "fastlane"
# Temporary workaround for https://github.com/fastlane/fastlane/issues/26682
gem "fastlane-sirp", git: "https://github.com/appbot/fastlane-sirp.git", ref: "sysrandom_fix"
gem "nokogiri"
gem "rubocop"

View File

@@ -23,6 +23,7 @@ GEM
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
artifactory (3.0.17)
ast (2.4.2)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.996.0)
@@ -216,6 +217,7 @@ GEM
json (2.7.5)
jwt (2.9.3)
base64
language_server-protocol (3.17.0.3)
mini_magick (4.13.2)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
@@ -233,10 +235,16 @@ GEM
racc (~> 1.4)
optparse (0.5.0)
os (1.1.4)
parallel (1.26.3)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
plist (3.7.1)
public_suffix (4.0.7)
racc (1.7.3)
rainbow (3.1.1)
rake (13.2.1)
regexp_parser (2.9.2)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
@@ -244,7 +252,20 @@ GEM
retriable (3.1.2)
rexml (3.3.9)
rouge (2.0.7)
rubocop (1.68.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.36.1)
parser (>= 3.3.1.0)
ruby-macho (2.5.1)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.5)
@@ -292,6 +313,7 @@ DEPENDENCIES
fastlane
fastlane-sirp!
nokogiri
rubocop
RUBY VERSION
ruby 2.7.5p203

View File

@@ -54,7 +54,7 @@ setup_permissions(
# ```
# flipper_config = ENV["NO_FLIPPER"] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled
linkage = ENV["USE_FRAMEWORKS"]
linkage = ENV.fetch( "USE_FRAMEWORKS", nil )
unless linkage.nil?
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
use_frameworks! linkage: linkage.to_sym
@@ -127,7 +127,7 @@ target "iNaturalistReactNative" do
end
end
installer.target_installation_results.pod_target_installation_results.each do | _pod_name, inst_result |
installer.target_installation_results.pod_target_installation_results.each_value do | inst_result |
inst_result.native_target.build_configurations.each do | build_config |
# For third party modules who have React-bridging dependency to search correct headers
build_config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) "

View File

@@ -13,9 +13,13 @@
"test": "jest tests/integration && jest tests/unit tests/helpers",
"test:clear": "jest --clearCache",
"test:memory": "jest --runInBand --logHeapUsage",
"lint": "npm run lint:eslint && npm run lint:flow",
"lint:eslint": "eslint . --fix",
"lint": "npm run lint:eslint && npm run lint:flow && npm run lint:rubocop",
"lint:fix": "npm run lint:eslint:fix && npm run lint:flow && npm run lint:rubocop:fix",
"lint:eslint": "eslint .",
"lint:eslint:fix": "eslint . --fix",
"lint:flow": "flow check",
"lint:rubocop": "bundle exec rubocop",
"lint:rubocop:fix": "bundle exec rubocop -A",
"lint:tsc": "tsc --allowJs false --noEmit",
"postinstall": "husky && patch-package",
"translate": "node src/i18n/i18ncli.js build",

View File

@@ -38,9 +38,7 @@ num_cleaned = 0
# doc.at("svg").remove_attribute "xmlns:inkscape"
# doc.at("svg").remove_attribute "xmlns:sodipodi"
doc.remove_namespaces!
File.open( path, "w" ) do | file |
file.write( doc.to_xml( indent: 2 ) )
end
File.write( path, doc.to_xml( indent: 2 ) )
num_cleaned += 1
end
puts "Cleaned #{num_cleaned} SVGs"