All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: Jason Tibbitts <tibbs@math.uh.edu>
2 " Description: Adds support for checking RPM spec files with rpmlint
4 " rpmlint will produce varions types of output:
6 " Lines like the following are output when the file is simply not able to be
7 " parsed by rpmspec -P:
8 " apcupsd.spec: E: specfile-error warning: bogus date in %changelog: Mon Oct 1 2005 - Foo
9 " apcupsd.spec: E: specfile-error error: %changelog not in descending chronological order
10 " They do not contain a line number, and there's not a whole lot that can be
11 " done to locate them besides grep for them. rpmlint is just passing the
12 " output from rpm along with the filename, an error indicator, and an error
15 " Lines like the following:
16 " cyrus-imapd.spec:23: W: macro-in-comment %version
17 " cyrus-imapd.spec:18: E: hardcoded-library-path in %_prefix/lib/%name
18 " indicate warnings and errors, respectively. No column numbers are provided
21 " apcupsd.spec: I: checking
22 " apcupsd.spec: I: checking-url https://downloads.sourceforge.net/apcupsd/apcupsd-3.14.14.tar.gz (timeout 10 seconds)
23 " are merely informational and are only output when -v is passed. But they
24 " may be useful in a log to know why things are taking so long.
26 " And this is always output at the end and should just be ignored:
27 " 0 packages and 1 specfiles checked; 4 errors, 0 warnings.
29 call ale#Set('spec_rpmlint_executable', 'rpmlint')
30 call ale#Set('spec_rpmlint_options', '')
32 function! ale_linters#spec#rpmlint#GetCommand(buffer, version) abort
33 if ale#semver#GTE(a:version, [2, 0, 0])
34 " The -o/--option flag was removed in version 2.0.0
35 let l:version_dependent_args = ''
37 let l:version_dependent_args = ' -o "NetworkEnabled False"'
41 \ . ale#Pad(ale#Var(a:buffer, 'spec_rpmlint_options'))
43 \ . l:version_dependent_args
47 function! ale_linters#spec#rpmlint#Handle(buffer, lines) abort
48 " let l:pat_inform = '^.\+: I: \(.+\)'
49 let l:pat_errwarn = '^.\+:\(\d\+\): \([EW]\): \(.\+\)'
50 let l:pat_baderr = '^.\+: E: \(.\+\)'
54 let l:match_errwarn = matchlist(l:line, l:pat_errwarn)
55 let l:match_baderr = matchlist(l:line, l:pat_baderr)
57 if len(l:match_errwarn) > 0
58 let l:text = l:match_errwarn[3]
59 let l:type = l:match_errwarn[2]
60 let l:lnum = l:match_errwarn[1] + 0
61 elseif len(l:match_baderr) > 0
62 let l:text = l:match_baderr[1]
80 call ale#linter#Define('spec', {
82 \ 'executable': {b -> ale#Var(b, 'spec_rpmlint_executable')},
83 \ 'command': {buffer -> ale#semver#RunWithVersionCheck(
85 \ ale#Var(buffer, 'spec_rpmlint_executable'),
87 \ function('ale_linters#spec#rpmlint#GetCommand'),
89 \ 'callback': 'ale_linters#spec#rpmlint#Handle',