Class: Pod::Command::Lib::Lint

Inherits:
Pod::Command::Lib show all
Defined in:
lib/cocoapods/command/lib/lint.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pod::Command

#ensure_master_spec_repo_exists!, report_error, run

Methods included from Pod::Config::Mixin

#config

Constructor Details

#initialize(argv) ⇒ Lint

Returns a new instance of Lint.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/cocoapods/command/lib/lint.rb', line 34

def initialize(argv)
  @quick           = argv.flag?('quick')
  @allow_warnings  = argv.flag?('allow-warnings')
  @clean           = argv.flag?('clean', true)
  @fail_fast       = argv.flag?('fail-fast', false)
  @subspecs        = argv.flag?('subspecs', true)
  @only_subspec    = argv.option('subspec')
  @use_frameworks  = !argv.flag?('use-libraries')
  @source_urls     = argv.option('sources', 'https://github.com/CocoaPods/Specs.git').split(',')
  @platforms       = argv.option('platforms', '').split(',')
  @private         = argv.flag?('private', false)
  @swift_version   = argv.option('swift-version', nil)
  @skip_import_validation = argv.flag?('skip-import-validation', false)
  @skip_tests = argv.flag?('skip-tests', false)
  @podspecs_paths = argv.arguments!
  super
end

Class Method Details

.optionsObject



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

def self.options
  [
    ['--quick', 'Lint skips checks that would require to download and build the spec'],
    ['--allow-warnings', 'Lint validates even if warnings are present'],
    ['--subspec=NAME', 'Lint validates only the given subspec'],
    ['--no-subspecs', 'Lint skips validation of subspecs'],
    ['--no-clean', 'Lint leaves the build directory intact for inspection'],
    ['--fail-fast', 'Lint stops on the first failing platform or subspec'],
    ['--use-libraries', 'Lint uses static libraries to install the spec'],
    ['--sources=https://github.com/artsy/Specs,master', 'The sources from which to pull dependent pods ' \
     '(defaults to https://github.com/CocoaPods/Specs.git). ' \
     'Multiple sources must be comma-delimited.'],
    ['--platforms=ios,macos', 'Lint against specific platforms' \
      '(defaults to all platforms supported by the podspec).' \
      'Multiple platforms must be comma-delimited'],
    ['--private', 'Lint skips checks that apply only to public specs'],
    ['--swift-version=VERSION', 'The SWIFT_VERSION that should be used to lint the spec. ' \
     'This takes precedence over a .swift-version file.'],
    ['--skip-import-validation', 'Lint skips validating that the pod can be imported'],
    ['--skip-tests', 'Lint skips building and running tests during validation'],
  ].concat(super)
end

Instance Method Details

#runObject



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/cocoapods/command/lib/lint.rb', line 56

def run
  UI.puts
  podspecs_to_lint.each do |podspec|
    validator                = Validator.new(podspec, @source_urls, @platforms)
    validator.local          = true
    validator.quick          = @quick
    validator.no_clean       = !@clean
    validator.fail_fast      = @fail_fast
    validator.allow_warnings = @allow_warnings
    validator.no_subspecs    = !@subspecs || @only_subspec
    validator.only_subspec   = @only_subspec
    validator.use_frameworks = @use_frameworks
    validator.ignore_public_only_results = @private
    validator.swift_version = @swift_version
    validator.skip_import_validation = @skip_import_validation
    validator.skip_tests = @skip_tests
    validator.validate

    unless @clean
      UI.puts "Pods workspace available at `#{validator.validation_dir}/App.xcworkspace` for inspection."
      UI.puts
    end
    if validator.validated?
      UI.puts "#{validator.spec.name} passed validation.".green
    else
      spec_name = podspec
      spec_name = validator.spec.name if validator.spec
      message = "#{spec_name} did not pass validation, due to #{validator.failure_reason}."

      if @clean
        message << "\nYou can use the `--no-clean` option to inspect " \
          'any issue.'
      end
      raise Informative, message
    end
  end
end

#validate!Object



52
53
54
# File 'lib/cocoapods/command/lib/lint.rb', line 52

def validate!
  super
end