Skip to content
Closed
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,4 @@ build-iPhoneSimulator/
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
.DS_Store
Gemfile.lock
37 changes: 0 additions & 37 deletions Gemfile.lock

This file was deleted.

16 changes: 10 additions & 6 deletions lib/typocop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@
require 'typocop/repo'
require 'typo_checker'

GITHUB_TOKEN = ENV['GITHUB_TOKEN'] || ''
PULL_ID = ENV['PULL_REQUEST_ID']
GITHUB_BASE_REF = ENV['GITHUB_BASE_REF'] || 'main'
GITHUB_TOKEN = ENV.fetch('GITHUB_TOKEN') { raise 'GITHUB_TOKEN is required' }
PULL_ID = ENV.fetch('PULL_REQUEST_ID') { raise 'PULL_REQUEST_ID is required' }
GITHUB_BASE_REF = ENV.fetch('GITHUB_BASE_REF') { raise 'GITHUB_BASE_REF is required' }
BASE_BRANCH = GITHUB_BASE_REF.start_with?('origin/') ? GITHUB_BASE_REF : "origin/#{GITHUB_BASE_REF}"

module Typocop
def self.execute(settings)
repo = Repo.new
paths = repo.patch_additions.map(&:path)

return unless paths.any?

excludes = settings.excludes
skips = settings.skips
typo_checker = TypoChecker::Checker.new(excludes, skips, stdoutput = false)
typo_checker = TypoChecker::Checker.new(paths: paths, excludes: excludes, skips: skips, stdoutput: false)
found_typos = typo_checker.scan_repo('.')

if found_typos.empty?
puts 'No typos.'
puts 'No typos found'
else
cops = Cops.new(found_typos)
repo = Repo.new
client = Client.new(repo)
client.execute(cops.cops)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/typocop/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def suggestion_comment(typos)
end

def line_content(cop)
patch = @repo.patch_additions.find { |patch| patch.path == cop.path }
patch = @repo.patch_additions.find { |p| p.path == cop.path }
patch.added_lines.find { |line| line.new_lineno == cop.line }.content
end

Expand Down
10 changes: 4 additions & 6 deletions lib/typocop/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ def initialize(setting_path)
private

def load_settings(setting_path)
begin
YAML.load_file(setting_path)
rescue StandardError => e
puts "Error loading YAML file: #{e.message}"
return {}
end
YAML.load_file(setting_path)
rescue StandardError => e
puts "Error loading YAML file: #{e.message}"
{}
end
end
end
Loading