adlint-postfilter 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/INSTALL ADDED
@@ -0,0 +1,61 @@
1
+ --
2
+ ___ ____ __ ___ _________
3
+ / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
4
+ / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
5
+ / __ |/ /_/ / /___/ / /| / / /
6
+ /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
7
+
8
+ This file is part of AdLint.
9
+
10
+ AdLint is free software: you can redistribute it and/or modify it under the
11
+ terms of the GNU General Public License as published by the Free Software
12
+ Foundation, either version 3 of the License, or (at your option) any later
13
+ version.
14
+
15
+ AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
16
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License along with
20
+ AdLint. If not, see <http://www.gnu.org/licenses/>.
21
+
22
+ ++
23
+
24
+ === Requirements
25
+
26
+ * \AdLint 1.0.0 or later [*mandatory*]
27
+
28
+
29
+ === Installation
30
+
31
+ You can install adlint-postfilter by following command.
32
+
33
+ If \AdLint 1.0.0 or later version has not been installed, it will be installed
34
+ automatically before installing adlint-postfilter.
35
+
36
+ % gem install adlint-postfilter
37
+ or
38
+ % sudo gem install adlint-postfilter
39
+
40
+
41
+ === Usage
42
+
43
+ First, copy a template of adlint-postfilter's configuration file to the root of
44
+ the analysis project and transform the analysis +GNUmakefile+.
45
+
46
+ % cd path/to/analysis/project
47
+ % adlint_flt -it
48
+
49
+ Following files will be generated or overwritten.
50
+
51
+ * [+adlint_postfilter.yml+] Project-wide message suppression settings.
52
+ * [+GNUmakefile+] Overwritten +GNUmakefile+ to use adlint-postfilter.
53
+ * [+GNUmakefile.orig+] Backup of the original +GNUmakefile+.
54
+
55
+ Second, edit project-wide message suppression settings in
56
+ +adlint_postfilter.yml+ and add translation-unit-wide and line-wise message
57
+ control annotations to source files if needed.
58
+
59
+ Finally, do analysis by ordinary instructions of the \AdLint analysis.
60
+
61
+ % make verbose-all
data/MANIFEST ADDED
@@ -0,0 +1,20 @@
1
+ AUTHORS
2
+ COPYING
3
+ ChangeLog
4
+ INSTALL
5
+ MANIFEST
6
+ NEWS
7
+ README
8
+ Rakefile
9
+ bin/adlint_flt
10
+ etc/conf.d/adlint_postfilter.yml
11
+ lib/adlint/postfilter.rb
12
+ lib/adlint/postfilter/annotate.rb
13
+ lib/adlint/postfilter/command.rb
14
+ lib/adlint/postfilter/config.rb
15
+ lib/adlint/postfilter/content.rb
16
+ lib/adlint/postfilter/driver.rb
17
+ lib/adlint/postfilter/filter.rb
18
+ lib/adlint/postfilter/path.rb
19
+ lib/adlint/postfilter/suppress.rb
20
+ lib/adlint/postfilter/version.rb
data/NEWS ADDED
@@ -0,0 +1,35 @@
1
+ --
2
+ ___ ____ __ ___ _________
3
+ / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
4
+ / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
5
+ / __ |/ /_/ / /___/ / /| / / /
6
+ /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
7
+
8
+ This file is part of AdLint.
9
+
10
+ AdLint is free software: you can redistribute it and/or modify it under the
11
+ terms of the GNU General Public License as published by the Free Software
12
+ Foundation, either version 3 of the License, or (at your option) any later
13
+ version.
14
+
15
+ AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
16
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License along with
20
+ AdLint. If not, see <http://www.gnu.org/licenses/>.
21
+
22
+ ++
23
+
24
+ === 1.0.0 is released (2012-04-17)
25
+
26
+ This is the initial GA release of adlint-postfilter.
27
+
28
+ ==== Implemented features
29
+
30
+ * Platform headers' warning message suppression
31
+ * AdLint initial headers' warning message suppression
32
+ * Project-wide warning message suppression
33
+ * Translation-unit-wide warning message control (both enable/disable
34
+ suppressions)
35
+ * Line-wise warning message control (both enable/disable suppressions)
data/README ADDED
@@ -0,0 +1,192 @@
1
+ --
2
+ ___ ____ __ ___ _________
3
+ / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
4
+ / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
5
+ / __ |/ /_/ / /___/ / /| / / /
6
+ /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
7
+
8
+ This file is part of AdLint.
9
+
10
+ AdLint is free software: you can redistribute it and/or modify it under the
11
+ terms of the GNU General Public License as published by the Free Software
12
+ Foundation, either version 3 of the License, or (at your option) any later
13
+ version.
14
+
15
+ AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
16
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
+ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
+
19
+ You should have received a copy of the GNU General Public License along with
20
+ AdLint. If not, see <http://www.gnu.org/licenses/>.
21
+
22
+ ++
23
+
24
+ == What is
25
+
26
+ adlint-postfilter is an ad-hoc filtering wrapper for \AdLint to suppress
27
+ useless warning messages.
28
+
29
+ == News
30
+
31
+ :include:NEWS
32
+
33
+ == How to Install
34
+
35
+ :include:INSTALL
36
+
37
+
38
+ == Interface
39
+
40
+ === +adlint_flt+ command
41
+
42
+ % adlint_flt --help
43
+ Usage: adlint_flt --analyze <analysis command line> | [other options]
44
+
45
+ Analysis Options:
46
+ -A, --analyze Execute AdLint analysis command
47
+ -P, --sma-strip NUM Use NUM as VPATH_COMPONENTS (CMA only)
48
+
49
+ Other Options:
50
+ -i, --install Generate adlint_filter.yml template
51
+ -t, --transform Transform project's GNUmakefile
52
+ -f, --force Force to overwrite existing files
53
+ --version Display version information
54
+ --copyright Display copyright information
55
+ --prefix Display prefix directory of adlint-postfilter
56
+ -h, --help Display this message
57
+
58
+ === Project-wide message control file (+adlint_postfilter.yml+)
59
+
60
+ +adlint_postfilter.yml+ file should be written in YAML format.
61
+
62
+ ==== Syntax in informal BNF
63
+
64
+ adlint-postfilter-yml : message-traits-section
65
+
66
+ message-traits-section : "message_traits:" NEW_LINE suppression-list-section NEW_LINE individual-suppression-control-section NEW_LINE
67
+
68
+ suppression-list-section : SPACE SPACE "suppression_list:" NEW_LINE message-suppression-list
69
+
70
+ message-suppression-list :
71
+ | message-suppression-list message-suppression-record
72
+
73
+ message-suppression-record : SPACE SPACE SPACE SPACE "-" message-id NEW_LINE
74
+
75
+ message-id : A string exactly matches with regexp /[WC][0-9]{4}/
76
+
77
+ individual-suppression-control-section : SPACE SPACE "enable_individual_suppression_control:" SPACE boolean-value NEW_LINE
78
+
79
+ boolean-value : "true" | "false"
80
+
81
+ ==== Example
82
+
83
+ % cat adlint_postfilter.yml
84
+ ...snip...
85
+ message_traits:
86
+
87
+ suppression_list:
88
+ - W0001
89
+ - W0002
90
+ - W0003
91
+
92
+ enable_individual_suppression_control : true
93
+ ...snip...
94
+
95
+ === Translation-unit-wide message control annotation
96
+
97
+ A translation-unit-wide message control annotation should be written as an
98
+ ordinary comment of C language.
99
+
100
+ It can appear at any line in the target source file.
101
+
102
+ ==== Syntax in informal BNF
103
+
104
+ tunit-wide-annotation : "/*" tunit-wide-message-controller "*/"
105
+ | "/*" arbitrary-comment tunit-wide-message-controller "*/"
106
+ | "/*" tunit-wide-message-controller arbitrary-comment "*/"
107
+ | "/*" arbitrary-comment tunit-wide-message-controller arbitrary-comment "*/"
108
+
109
+ arbitrary-comment : A sequence of any characters which does not match with regexp /ADLINT:TUNIT:/i
110
+
111
+ tunit-wide-message-controller : tunit-wide-message-control-head "[" message-control-list "]"
112
+
113
+ tunit-wide-message-control-head : "ADLINT:TUNIT:"
114
+
115
+ message-control-list : message-control
116
+ | message-control-list "," message-control
117
+
118
+ message-control : message-suppression-activation
119
+ | message-suppression-deactivation
120
+
121
+ message-suppression-activation : "-" message-id
122
+
123
+ message-suppression-deactivation : "+" message-id
124
+
125
+ message-id : Described in `Project-wide message control file' section
126
+
127
+ ==== Example
128
+
129
+ % head target.c
130
+ /* ADLINT:TUNIT:[-W0001,-W0002,+W0003] added by yanoh */
131
+ ...snip...
132
+
133
+ === Line-wise message control annotation
134
+
135
+ A line-wise message control annotation should be written as an ordinary comment
136
+ of C language.
137
+
138
+ It should appear in the target line.
139
+
140
+ ==== Syntax in informal BNF
141
+
142
+ line-wise-annotation : "/*" line-wise-message-controller "*/"
143
+ | "/*" arbitrary-comment line-wise-message-controller "*/"
144
+ | "/*" line-wise-message-controller arbitrary-comment "*/"
145
+ | "/*" arbitrary-comment line-wise-message-controller arbitrary-comment "*/"
146
+
147
+ arbitrary-comment : A sequence of any characters which does not match to regexp /ADLINT::/i and /ADLINT:LINE:/i
148
+
149
+ line-wise-message-controller : line-wise-message-control-head "[" message-control-list "]"
150
+
151
+ line-wise-message-control-head : "ADLINT::" | "ADLINT:LINE:"
152
+
153
+ message-control-list : Described in `Translation-unit-wide message control annotation' section
154
+
155
+ message-control : Described in `Translation-unit-wide message control annotation' section
156
+
157
+ message-suppression-activation : Described in `Translation-unit-wide message control annotation' section
158
+
159
+ message-suppression-deactivation : Described in `Translation-unit-wide message control annotation' section
160
+
161
+ message-id : Described in `Translation-unit-wide message control annotation' section
162
+
163
+ ==== Example
164
+
165
+ % cat target.c
166
+ ...snip...
167
+ const unsigned int ui1 = -1; /* ADLINT:LINE:[-W0607,+W0167] added by yanoh */
168
+ const unsigned int ui2 = -1; /* FIXME: ADLINT::[-W0607,+W0167] added by yanoh */
169
+ ...snip...
170
+
171
+
172
+ == License
173
+
174
+ Copyright (C) 2010-2012, {OGIS-RI}[http://www.ogis-ri.co.jp/] Co.,Ltd.
175
+
176
+ adlint-postfilter is free software: you can redistribute it and/or modify it
177
+ under the terms of the GNU General Public License as published by the Free
178
+ Software Foundation, either version 3 of the License, or (at your option) any
179
+ later version.
180
+
181
+ adlint-postfilter is distributed in the hope that it will be useful, but
182
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
183
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
184
+ details.
185
+
186
+ You should have received a copy of the GNU General Public License along with
187
+ adlint-postfilter. If not, see
188
+ <{http\://www.gnu.org/licenses/}[http://www.gnu.org/licenses/]>.
189
+
190
+ == Authors
191
+
192
+ :include:AUTHORS
data/Rakefile ADDED
@@ -0,0 +1,86 @@
1
+ #--
2
+ # ___ ____ __ ___ _________
3
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
4
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
5
+ # / __ |/ /_/ / /___/ / /| / / /
6
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
7
+ #
8
+ # This file is part of AdLint.
9
+ #
10
+ # AdLint is free software: you can redistribute it and/or modify it under the
11
+ # terms of the GNU General Public License as published by the Free Software
12
+ # Foundation, either version 3 of the License, or (at your option) any later
13
+ # version.
14
+ #
15
+ # AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
16
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU General Public License along with
20
+ # AdLint. If not, see <http://www.gnu.org/licenses/>.
21
+ #
22
+ #++
23
+
24
+ require "rubygems/package_task"
25
+ require "rdoc/task"
26
+
27
+ $: << File.expand_path("lib", File.dirname(__FILE__))
28
+ require "adlint/postfilter/version"
29
+
30
+ task :default => [:gem]
31
+ task :clobber => [:clobber_package, :clobber_rdoc]
32
+
33
+ gemspec = Gem::Specification.new do |s|
34
+ s.name = "adlint-postfilter"
35
+ s.version = AdLint::Postfilter::SHORT_VERSION
36
+ s.date = AdLint::Postfilter::RELEASE_DATE
37
+ s.homepage = "http://adlint-goodies.sourceforge.net/"
38
+ s.licenses = ["GPLv3+: GNU General Public License version 3 or later"]
39
+ s.author = "Yutaka Yanoh"
40
+ s.email = "yanoh@users.sourceforge.net"
41
+ s.summary = "An ad-hoc filtering wrapper for AdLint"
42
+ s.description = <<EOS
43
+ adlint-postfilter is an ad-hoc filtering wrapper for AdLint to suppress useless
44
+ warning messages.
45
+ EOS
46
+
47
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
48
+
49
+ s.executables = %w(adlint_flt)
50
+ s.require_paths = %w(lib)
51
+ manifest_fpath = File.expand_path("MANIFEST", File.dirname(__FILE__))
52
+ s.files = File.readlines(manifest_fpath).map { |str| str.chomp }
53
+
54
+ s.has_rdoc = true
55
+ s.extra_rdoc_files = %w(README)
56
+ s.rdoc_options = ["--main", "README", "--charset", "utf-8"]
57
+
58
+ s.add_dependency("adlint", ">= 1.0.0")
59
+ end
60
+
61
+ Gem::PackageTask.new(gemspec) do |pkg|
62
+ pkg.need_zip = true
63
+ pkg.need_tar_bz2 = true
64
+ end
65
+
66
+ RDoc::Task.new(:rdoc) do |rd|
67
+ rd.rdoc_dir = "rdoc"
68
+ rd.title = "adlint-postfilter #{AdLint::Postfilter::SHORT_VERSION}"
69
+ rd.main = "README"
70
+ rd.rdoc_files.include("README")
71
+ rd.rdoc_files.include("bin/*")
72
+ rd.rdoc_files.include("lib/**/*.rb")
73
+ rd.options << "--charset=utf-8" << "--all"
74
+ end
75
+
76
+ desc "Remove package products and RDoc HTML files"
77
+ task :clobber
78
+
79
+ desc "Generate tags file"
80
+ task :tags do
81
+ ctags *Dir["bin/*", "lib/**/*.rb"]
82
+ end
83
+
84
+ def ctags(*files)
85
+ sh "ctags " + files.join(" ")
86
+ end
data/bin/adlint_flt ADDED
@@ -0,0 +1,154 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # An ad-hoc filtering wrapper command for AdLint to suppress useless warning
4
+ # messages.
5
+ #
6
+ # Author:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
7
+ # Copyright:: Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
8
+ # License:: GPLv3+: GNU General Public License version 3 or later
9
+ #
10
+ # Owner:: Yutaka Yanoh <mailto:yanoh@users.sourceforge.net>
11
+
12
+ #--
13
+ # ___ ____ __ ___ _________
14
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
15
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
16
+ # / __ |/ /_/ / /___/ / /| / / /
17
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
18
+ #
19
+ # This file is part of AdLint.
20
+ #
21
+ # AdLint is free software: you can redistribute it and/or modify it under the
22
+ # terms of the GNU General Public License as published by the Free Software
23
+ # Foundation, either version 3 of the License, or (at your option) any later
24
+ # version.
25
+ #
26
+ # AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
27
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
28
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
29
+ #
30
+ # You should have received a copy of the GNU General Public License along with
31
+ # AdLint. If not, see <http://www.gnu.org/licenses/>.
32
+ #
33
+ #++
34
+
35
+ require "pathname"
36
+
37
+ $bindir = Pathname.new(__FILE__).realpath.dirname
38
+ $prefix = Pathname.new("..").expand_path($bindir)
39
+ $libdir = Pathname.new("lib").expand_path($prefix)
40
+ $etcdir = Pathname.new("etc").expand_path($prefix)
41
+
42
+ $stdout.set_encoding(Encoding.default_external)
43
+ $stderr.set_encoding(Encoding.default_external)
44
+
45
+ $:.unshift($libdir.to_s)
46
+
47
+ require "adlint/postfilter"
48
+
49
+ POSTFILTER_VERSION = "adlint-postfilter #{AdLint::Postfilter::VERSION}"
50
+
51
+ USAGE = <<EOS
52
+ Usage: adlint_flt --analyze <analysis command line> | [other options]
53
+
54
+ Analysis Options:
55
+ -A, --analyze Execute AdLint analysis command
56
+ -V, --src-vpath DIR Use DIR as VPATH (CMA only)
57
+
58
+ Other Options:
59
+ -i, --install Generate adlint_filter.yml template
60
+ -t, --transform Transform project's GNUmakefile
61
+ -f, --force Force to overwrite existing files
62
+ --version Display version information
63
+ --copyright Display copyright information
64
+ --prefix Display prefix directory of adlint-postfilter
65
+ -h, --help Display this message
66
+ EOS
67
+
68
+ require "getoptlong"
69
+
70
+ parser = GetoptLong.new(["--analyze", "-A", GetoptLong::NO_ARGUMENT],
71
+ ["--src-vpath", "-V", GetoptLong::REQUIRED_ARGUMENT],
72
+ ["--install", "-i", GetoptLong::NO_ARGUMENT],
73
+ ["--transform", "-t", GetoptLong::NO_ARGUMENT],
74
+ ["--force", "-f", GetoptLong::NO_ARGUMENT],
75
+ ["--version", GetoptLong::NO_ARGUMENT],
76
+ ["--copyright", GetoptLong::NO_ARGUMENT],
77
+ ["--prefix", GetoptLong::NO_ARGUMENT],
78
+ ["--help", "-h", GetoptLong::NO_ARGUMENT])
79
+ parser.quiet = true
80
+
81
+ begin
82
+ actions = {}
83
+ config_fpath = Pathname.new("./adlint_postfilter.yml")
84
+ makefile_fpath = Pathname.new("./GNUmakefile")
85
+ command_line = nil
86
+ force_overwrite = false
87
+ src_vpath = nil
88
+
89
+ parser.each_option do |optname, optarg|
90
+ case optname
91
+ when "--analyze"
92
+ actions[:analyze] = true
93
+ command_line = ARGV.join(" ")
94
+ break
95
+ when "--src-vpath"
96
+ src_vpath = Pathname.new(optarg)
97
+ when "--install"
98
+ actions[:install] = true
99
+ when "--transform"
100
+ actions[:transform] = true
101
+ when "--force"
102
+ force_overwrite = true
103
+ when "--version"
104
+ puts POSTFILTER_VERSION, AdLint::Postfilter::AUTHOR
105
+ exit 0
106
+ when "--copyright"
107
+ puts AdLint::Postfilter::COPYRIGHT
108
+ exit 0
109
+ when "--prefix"
110
+ puts $prefix
111
+ exit 0
112
+ when "--help"
113
+ puts USAGE
114
+ exit 0
115
+ end
116
+ end
117
+ rescue
118
+ end
119
+
120
+ if actions.empty?
121
+ $stderr.puts "#{File.basename(__FILE__)}: nothing to be done"
122
+ $stderr.puts USAGE
123
+ exit 10
124
+ end
125
+
126
+ if actions[:install]
127
+ if !config_fpath.exist? || force_overwrite
128
+ AdLint::Postfilter.install_config_template(config_fpath)
129
+ else
130
+ $stderr.puts "#{File.basename(__FILE__)}: #{config_fpath} already exists"
131
+ exit 10
132
+ end
133
+ end
134
+
135
+ if actions[:transform]
136
+ if makefile_fpath.exist?
137
+ AdLint::Postfilter.transform_makefile(makefile_fpath)
138
+ else
139
+ $stderr.puts "#{File.basename(__FILE__)}: cannot access #{makefile_fpath}"
140
+ exit 10
141
+ end
142
+ end
143
+
144
+ if actions[:analyze]
145
+ if command_line
146
+ exit AdLint::Postfilter.run(config_fpath, command_line, src_vpath)
147
+ else
148
+ $stderr.puts "#{File.basename(__FILE__)}: no analysis command line"
149
+ $stderr.puts USAGE
150
+ exit 10
151
+ end
152
+ end
153
+
154
+ exit 0
@@ -0,0 +1,21 @@
1
+ # ___ ____ __ ___ _________
2
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
3
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
4
+ # / __ |/ /_/ / /___/ / /| / / /
5
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
6
+ #
7
+ # Configuration file for adlint_flt command of adlint-postfilter.
8
+ #
9
+
10
+ message_traits:
11
+
12
+ # Project-wide message suppressions.
13
+ # Ex.
14
+ # suppression_list:
15
+ # - W0001
16
+ # - W0002
17
+ # - C0003
18
+ suppression_list:
19
+
20
+ # Enable message control annotations in source files?
21
+ enable_individual_suppression_control: true