Class: Danger::DangerMissingCodeowners
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerMissingCodeowners
- Defined in:
- lib/missing_codeowners/plugin.rb
Overview
Parses the CODEOWNERS file and verifies if files have at least one owner. Works with GitHub and GitLab. Results are passed out as a table in markdown.
Instance Attribute Summary collapse
-
#files_missing_codeowners ⇒ Array<String>
The list of files that are missing owners.
-
#max_number_of_files_to_report ⇒ Int
The maximum number of files missing owners Danger should report.
-
#severity ⇒ String
Defines the severity level of the execution.
-
#verbose ⇒ Bool
Provides additional logging diagnostic information.
-
#verify_all_files ⇒ Bool
Whether all files or only ones in PR diff to be reported.
Instance Method Summary collapse
-
#verify ⇒ void
Verifies git added and modified files for missing owners.
Instance Attribute Details
#files_missing_codeowners ⇒ Array<String>
The list of files that are missing owners.
21 22 23 |
# File 'lib/missing_codeowners/plugin.rb', line 21 def files_missing_codeowners @files_missing_codeowners end |
#max_number_of_files_to_report ⇒ Int
The maximum number of files missing owners Danger should report. Default is 100.
31 32 33 |
# File 'lib/missing_codeowners/plugin.rb', line 31 def max_number_of_files_to_report @max_number_of_files_to_report end |
#severity ⇒ String
Defines the severity level of the execution. Possible values are: ‘error’ or ‘warning’. Default is ‘error’.
36 37 38 |
# File 'lib/missing_codeowners/plugin.rb', line 36 def severity @severity end |
#verbose ⇒ Bool
Provides additional logging diagnostic information. Default is false.
41 42 43 |
# File 'lib/missing_codeowners/plugin.rb', line 41 def verbose @verbose end |
#verify_all_files ⇒ Bool
Whether all files or only ones in PR diff to be reported. Default is false.
26 27 28 |
# File 'lib/missing_codeowners/plugin.rb', line 26 def verify_all_files @verify_all_files end |
Instance Method Details
#verify ⇒ void
This method returns an undefined value.
Verifies git added and modified files for missing owners. Generates a markdown list of warnings for the prose in a corpus of .markdown and .md files.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/missing_codeowners/plugin.rb', line 49 def verify @verify_all_files ||= false @max_number_of_files_to_report ||= 100 @severity ||= "error" @verbose ||= false files = files_to_verify codeowners_path = find_codeowners_file codeowners_lines = read_codeowners_file(codeowners_path) codeowners_spec = parse_codeowners_spec(codeowners_lines) @files_missing_codeowners = files.reject { |file| codeowners_spec.match file } return if @files_missing_codeowners.empty? log "Files missing CODEOWNERS:" log @files_missing_codeowners.join("\n") markdown (@files_missing_codeowners, @max_number_of_files_to_report) = "Add CODEOWNERS rules to match all files." @severity == "error" ? (fail ) : (warn ) end |