Class: PropertyGenerator::Linter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Linter

Returns a new instance of Linter.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/linter/linter.rb', line 9

def initialize(path)
  ignore_list = %w[README.md .cpsignore Jenkinsfile Gemfile Gemfile.lock]
  invalid_paths = PropertyGenerator.invalid_paths(path, ignore_list)
  begin
    @ignored_tests = YAML.load_file("#{path}/.cpsignore")
  rescue StandardError
    @ignored_tests = {}
  end
  @config_linter = PropertyGenerator::ConfigLinter.new("#{path}/config/config.yml", @ignored_tests['config'] || [])
  @globals_linter = PropertyGenerator::GlobalsLinter.new("#{path}/globals/", @config_linter.configs, @ignored_tests['globals'] || [])
  @services_linter = PropertyGenerator::ServicesLinter.new("#{path}/services/", @config_linter.configs, @ignored_tests['services'] || [])

  unless @ignored_tests['display_skipped_tests'].nil?
    if @ignored_tests['display_skipped_tests']
      @ignored_tests.delete('display_skipped_tests')
    else
      @ignored_tests = []
    end
  end

  @report = PropertyGenerator::Report.new(invalid_paths, @ignored_tests)
end

Instance Attribute Details

#config_linterObject

Returns the value of attribute config_linter.



7
8
9
# File 'lib/linter/linter.rb', line 7

def config_linter
  @config_linter
end

#globals_linterObject

Returns the value of attribute globals_linter.



7
8
9
# File 'lib/linter/linter.rb', line 7

def globals_linter
  @globals_linter
end

#ignored_testsObject

Returns the value of attribute ignored_tests.



7
8
9
# File 'lib/linter/linter.rb', line 7

def ignored_tests
  @ignored_tests
end

#reportObject

Returns the value of attribute report.



7
8
9
# File 'lib/linter/linter.rb', line 7

def report
  @report
end

#services_linterObject

Returns the value of attribute services_linter.



7
8
9
# File 'lib/linter/linter.rb', line 7

def services_linter
  @services_linter
end

Instance Method Details

#display_reportObject



49
50
51
# File 'lib/linter/linter.rb', line 49

def display_report
  @report.display_report
end

#fail_checkObject



41
42
43
44
45
46
47
# File 'lib/linter/linter.rb', line 41

def fail_check
  if @report.has_a_test_failed || @report.has_a_file_failed_to_load
    true
  else
    false
  end
end

#run_testsObject



32
33
34
35
36
37
38
39
# File 'lib/linter/linter.rb', line 32

def run_tests
  config_report = @config_linter.run_config_tests
  globals_report = @globals_linter.run_globals_tests
  service_linter = @services_linter.run_services_tests
  @report.add_report(config_report)
  @report.add_report(globals_report)
  @report.add_report(service_linter)
end