Class: PmdTester::Options

Inherits:
Object
  • Object
show all
Includes:
PmdTester
Defined in:
lib/pmdtester/parsers/options.rb

Overview

The Options is a class responsible of parsing all the command line options

Constant Summary collapse

ANY =
'any'
LOCAL =
'local'
ONLINE =
'online'
SINGLE =
'single'
DEFAULT_CONFIG_PATH =
ResourceLocator.locate('config/all-java.xml')
DEFAULT_LIST_PATH =
ResourceLocator.locate('config/project-list.xml')
DEFAULT_BASELINE_URL_PREFIX =
'https://sourceforge.net/projects/pmd/files/pmd-regression-tester/'

Constants included from PmdTester

BASE, PATCH, PR_NUM_ENV_VAR, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PmdTester

#logger, logger

Constructor Details

#initialize(argv) ⇒ Options

Returns a new instance of Options.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/pmdtester/parsers/options.rb', line 39

def initialize(argv)
  options = parse(argv)
  @local_git_repo = options[:r]
  @base_branch = options[:b]
  @patch_branch = options[:p]
  @base_config = options[:bc]
  @patch_config = options[:pc]
  @config = options[:c]
  @project_list = options[:l]
  @mode = options[:m]
  @threads = options[:t]
  @html_flag = options[:f]
  @auto_config_flag = options[:a]
  @filter_with_patch_config = options.filter_with_patch_config?
  @debug_flag = options[:d]
  @filter_set = nil
  @keep_reports = options.keep_reports?
  @error_recovery = options.error_recovery?
  url = options[:baseline_download_url]
  @baseline_download_url_prefix = if url[-1] == '/'
                                    url
                                  else
                                    "#{url}/"
                                  end

  # if the 'config' option is selected then `config` overrides `base_config` and `patch_config`
  @base_config = @config if !@config.nil? && @mode == 'local'
  @patch_config = @config if !@config.nil? && @mode == 'local'

  logger.level = @debug_flag ? Logger::DEBUG : Logger::INFO
  check_options
end

Instance Attribute Details

#auto_config_flagObject (readonly)

Returns the value of attribute auto_config_flag.



31
32
33
# File 'lib/pmdtester/parsers/options.rb', line 31

def auto_config_flag
  @auto_config_flag
end

#base_branchObject (readonly)

Returns the value of attribute base_branch.



22
23
24
# File 'lib/pmdtester/parsers/options.rb', line 22

def base_branch
  @base_branch
end

#base_configObject

Returns the value of attribute base_config.



24
25
26
# File 'lib/pmdtester/parsers/options.rb', line 24

def base_config
  @base_config
end

#baseline_download_url_prefixObject (readonly)

Returns the value of attribute baseline_download_url_prefix.



37
38
39
# File 'lib/pmdtester/parsers/options.rb', line 37

def baseline_download_url_prefix
  @baseline_download_url_prefix
end

#configObject (readonly)

Returns the value of attribute config.



26
27
28
# File 'lib/pmdtester/parsers/options.rb', line 26

def config
  @config
end

#debug_flagObject (readonly)

Returns the value of attribute debug_flag.



33
34
35
# File 'lib/pmdtester/parsers/options.rb', line 33

def debug_flag
  @debug_flag
end

#error_recoveryObject (readonly)

Returns the value of attribute error_recovery.



36
37
38
# File 'lib/pmdtester/parsers/options.rb', line 36

def error_recovery
  @error_recovery
end

#filter_setObject

Returns the value of attribute filter_set.



34
35
36
# File 'lib/pmdtester/parsers/options.rb', line 34

def filter_set
  @filter_set
end

#filter_with_patch_configObject (readonly)

Returns the value of attribute filter_with_patch_config.



32
33
34
# File 'lib/pmdtester/parsers/options.rb', line 32

def filter_with_patch_config
  @filter_with_patch_config
end

#html_flagObject (readonly)

Returns the value of attribute html_flag.



30
31
32
# File 'lib/pmdtester/parsers/options.rb', line 30

def html_flag
  @html_flag
end

#keep_reportsObject (readonly)

Returns the value of attribute keep_reports.



35
36
37
# File 'lib/pmdtester/parsers/options.rb', line 35

def keep_reports
  @keep_reports
end

#local_git_repoObject (readonly)

Returns the value of attribute local_git_repo.



21
22
23
# File 'lib/pmdtester/parsers/options.rb', line 21

def local_git_repo
  @local_git_repo
end

#modeObject (readonly)

Returns the value of attribute mode.



28
29
30
# File 'lib/pmdtester/parsers/options.rb', line 28

def mode
  @mode
end

#patch_branchObject (readonly)

Returns the value of attribute patch_branch.



23
24
25
# File 'lib/pmdtester/parsers/options.rb', line 23

def patch_branch
  @patch_branch
end

#patch_configObject

Returns the value of attribute patch_config.



25
26
27
# File 'lib/pmdtester/parsers/options.rb', line 25

def patch_config
  @patch_config
end

#project_listObject (readonly)

Returns the value of attribute project_list.



27
28
29
# File 'lib/pmdtester/parsers/options.rb', line 27

def project_list
  @project_list
end

#threadsObject (readonly)

Returns the value of attribute threads.



29
30
31
# File 'lib/pmdtester/parsers/options.rb', line 29

def threads
  @threads
end