Class: TypoChecker::RepositoryScanner

Inherits:
Object
  • Object
show all
Defined in:
lib/typo_checker/repository_scanner.rb

Instance Method Summary collapse

Constructor Details

#initialize(repo_path, configuration) ⇒ RepositoryScanner

Returns a new instance of RepositoryScanner.



5
6
7
8
9
# File 'lib/typo_checker/repository_scanner.rb', line 5

def initialize(repo_path, configuration)
  @repo_path = repo_path
  @configuration = configuration
  @file_scanner = FileScanner.new(load_typos, configuration.stdoutput)
end

Instance Method Details

#scanObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/typo_checker/repository_scanner.rb', line 11

def scan
  cops = {}
  paths = @configuration.paths

  if paths.empty?
    # Find all files in the repository
    Find.find(@repo_path) do |path|
      next if exclude_path?(path)

      find_cops(cops, path)
    end
  else
    paths.each do |pattern|
      # Find files based on the pattern
      Dir.glob(File.join(@repo_path, pattern)) do |path|
        next if exclude_path?(path)

        find_cops(cops, path)
      end
    end
  end
  scan_result(cops)
end