adlint-exam-c_staging 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog ADDED
@@ -0,0 +1,33 @@
1
+ Fri Sep 21 16:48:06 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
2
+
3
+ * release.ga : 0.2.0
4
+ - Add requested code check W2001 which detects an absolute pathname
5
+ as argument of #include directive.
6
+ - Add requested code check W2002 which detects inclusion of a user
7
+ header by #include <...> directive.
8
+
9
+ Wed Sep 19 17:20:01 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
10
+
11
+ * release.rc : 0.1.1
12
+ - Add requested code check W2002 which detects inclusion of a user
13
+ header by #include <...> directive.
14
+
15
+ Wed Sep 19 16:11:38 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
16
+
17
+ * features/code_check/W2002.feature : Add W2002 specification.
18
+ * MANIFEST : Ditto.
19
+
20
+ * lib/adlint/exam/c_staging/cpp_check.rb : Add W2002 detection.
21
+
22
+ Thu Sep 13 17:23:37 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
23
+
24
+ * release.rc : 0.1.0
25
+ - Add requested code check W2001 which detects an absolute pathname
26
+ as argument of #include directive.
27
+
28
+ Thu Sep 13 16:32:44 2012 Yutaka Yanoh <yanoh@users.sourceforge.net>
29
+
30
+ * features/code_check/W2001.feature : Add W2001 specification.
31
+ * MANIFEST : Ditto.
32
+
33
+ * lib/adlint/exam/c_staging/cpp_check.rb : Add W2001 detection.
data/INSTALL ADDED
@@ -0,0 +1,98 @@
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
+ * Ruby 1.9.3-p0 or later for normal use [*mandatory*]
27
+ * GNU Make 3 or later to use adlintized Makefile [optional but recommended]
28
+ * Racc 1.4.7 for development [optional]
29
+
30
+ === Installation
31
+
32
+ Setup your Ruby interpreter.
33
+ Then, you can install \AdLint by following instruction.
34
+
35
+ % gem install adlint adlint-exam-c_staging
36
+ or
37
+ % sudo gem install adlint adlint-exam-c_staging
38
+
39
+ === Evaluation
40
+
41
+ Tiny sample C language projects are bundled with \AdLint gem.
42
+ You can evaluate \AdLint by following instructions.
43
+
44
+ First, copy \`intro_demo' project into your workspace. "+adlint+ +--prefix+"
45
+ command prints the prefix pathname of the \AdLint installation directory.
46
+
47
+ % cp -r `adlint --prefix`/share/demo/intro_demo .
48
+
49
+ Second, generate configuration files for \AdLint.
50
+
51
+ % cd intro_demo
52
+ % adlintize
53
+
54
+ Following files will be generated.
55
+
56
+ * [+GNUmakefile+] Automatic analysis Makefile for GNU Make.
57
+ * [+adlint_traits.yml+] \AdLint configuration file.
58
+ * [+adlint_pinit.h+] Project specific initial header file.
59
+ * [+adlint_cinit.h+] Compiler specific initial header file.
60
+ * [+adlint_all.sh+] Automatic analysis shell script.
61
+ * [+adlint_all.bat+] Automatic analysis mswin bat file.
62
+ * [+adlint_files.txt+] List file for sh script and bat file.
63
+
64
+ Third, edit +adlint_traits.yml+ to use adlint-exam-c_staging examination
65
+ package.
66
+
67
+ % cp adlint_traits.yml adlint_traits.yml.orig
68
+ % vi adlint_traits.yml
69
+ % diff -u adlint_traits.yml.orig adlint_traits.yml
70
+ --- adlint_traits.yml.orig 2012-09-13 15:16:12.345684410 +0900
71
+ +++ adlint_traits.yml 2012-09-13 15:16:46.312257169 +0900
72
+ @@ -17,6 +17,7 @@
73
+ # list to specify which examination packages are to be run.
74
+ exam_packages:
75
+ - "c_builtin"
76
+ + - "c_staging"
77
+
78
+ #
79
+ # Project specific traits section
80
+
81
+ Finally, do analysis.
82
+
83
+ % make verbose-all
84
+ adlint --verbose -t adlint_traits.yml -o . intro_demo.c
85
+ intro_demo.c [fin] |============================| 0.401s
86
+ intro_demo [fin] |============================| 0.029s
87
+ 1.125s user, 0.765s system, 00:00:01.89 total
88
+
89
+ Following files will be generated.
90
+
91
+ * [+intro_demo.i+] Preprocessed source of +intro_demo.c+.
92
+ * [+intro_demo.c.met.csv+] Single module code structure and metric information.
93
+ * [+intro_demo.c.msg.csv+] Single module warning messages.
94
+ * [+intro_demo.met.csv+] Cross module metric information.
95
+ * [+intro_demo.msg.csv+] Cross module warning messages.
96
+
97
+ \`+intro_demo.c.msg.csv+' will tell you that the control will never reach to
98
+ some statements and that division by zero will occur in \`+intro_demo.c+'.
data/MANIFEST ADDED
@@ -0,0 +1,17 @@
1
+ AUTHORS
2
+ COPYING
3
+ ChangeLog
4
+ INSTALL
5
+ MANIFEST
6
+ NEWS
7
+ README
8
+ Rakefile
9
+ TODO
10
+ etc/mesg.d/c_staging/en_US/messages.yml
11
+ etc/mesg.d/c_staging/ja_JP/messages.yml
12
+ features/code_check/W2001.feature
13
+ features/code_check/W2002.feature
14
+ features/step_definitions/code_check_steps.rb
15
+ features/support/env.rb
16
+ lib/adlint/exam/c_staging.rb
17
+ lib/adlint/exam/c_staging/cpp_check.rb
data/NEWS ADDED
@@ -0,0 +1,30 @@
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
+ === adlint-exam-c_staging 0.2.0 is released (2012-09-21)
25
+
26
+ ==== Including source code examination features
27
+
28
+ * W2001 detects that an absolute pathname as argument of #include directive
29
+ * W2002 detects that a header file under the project root directory is included
30
+ as a system header
data/README ADDED
@@ -0,0 +1,60 @@
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-exam-c_staging is an experimental C language code examination package
27
+ for \AdLint.
28
+
29
+ == News
30
+
31
+ :include:NEWS
32
+
33
+ == How to Install
34
+
35
+ :include:INSTALL
36
+
37
+ == License
38
+
39
+ Copyright (C) 2010-2012, {OGIS-RI}[http://www.ogis-ri.co.jp/] Co.,Ltd.
40
+
41
+ \AdLint is free software: you can redistribute it and/or modify it under the
42
+ terms of the GNU General Public License as published by the Free Software
43
+ Foundation, either version 3 of the License, or (at your option) any later
44
+ version.
45
+
46
+ \AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
47
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
48
+ PARTICULAR PURPOSE. See the GNU General Public License for more details.
49
+
50
+ You should have received a copy of the GNU General Public License along with
51
+ \AdLint. If not, see
52
+ <{http\://www.gnu.org/licenses/}[http://www.gnu.org/licenses/]>.
53
+
54
+ == TODO
55
+
56
+ :include:TODO
57
+
58
+ == Authors
59
+
60
+ :include:AUTHORS
data/Rakefile ADDED
@@ -0,0 +1,109 @@
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
+ require "rspec/core/rake_task"
27
+ require "cucumber/rake/task"
28
+
29
+ $: << File.expand_path("lib", File.dirname(__FILE__))
30
+ require "adlint/exam/c_staging"
31
+
32
+ task :default => [:gem]
33
+ #task :gem => [:doc]
34
+ #task :package => [:doc]
35
+
36
+ gemspec = Gem::Specification.new do |s|
37
+ s.name = "adlint-exam-c_staging"
38
+ s.version = AdLint::Exam::CStaging::Catalog.short_version
39
+ s.date = AdLint::Exam::CStaging::Catalog.release_date
40
+ s.homepage = "http://adlint.sourceforge.net/"
41
+ s.licenses = ["GPLv3+: GNU General Public License version 3 or later"]
42
+ s.author = "Yutaka Yanoh"
43
+ s.email = "yanoh@users.sourceforge.net"
44
+ s.summary = <<EOS
45
+ Experimental C language code examination package for AdLint
46
+ EOS
47
+ s.description = <<EOS
48
+ Experimental C language code examination package for AdLint
49
+ EOS
50
+
51
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
52
+
53
+ s.require_paths = %w(lib)
54
+ manifest_fpath = File.expand_path("MANIFEST", File.dirname(__FILE__))
55
+ s.files = File.readlines(manifest_fpath).map { |str| str.chomp }
56
+
57
+ s.has_rdoc = true
58
+ s.extra_rdoc_files = %w(README)
59
+ s.rdoc_options = ["--main", "README", "--charset", "utf-8"]
60
+
61
+ s.add_dependency("adlint", ">= 2.3.0")
62
+ end
63
+
64
+ Gem::PackageTask.new(gemspec) do |pkg|
65
+ pkg.need_zip = true
66
+ pkg.need_tar_bz2 = true
67
+ end
68
+
69
+ desc "Build Texinfo HTML files"
70
+ task :doc do
71
+ chdir "share/doc" do
72
+ make "all"
73
+ end
74
+ end
75
+
76
+ RDoc::Task.new(:rdoc) do |rd|
77
+ rd.rdoc_dir = "rdoc"
78
+ rd.title = "adlint-exam-c_staging " +
79
+ AdLint::Exam::CStaging::Catalog.short_version
80
+ rd.main = "README"
81
+ rd.rdoc_files.include("README")
82
+ rd.rdoc_files.include("lib/**/*.rb")
83
+ rd.options << "--charset=utf-8" << "--all"
84
+ end
85
+
86
+ desc "Remove package products and RDoc HTML files"
87
+ task :clobber
88
+
89
+ desc "Generate tags file"
90
+ task :tags do
91
+ ctags *Dir["bin/*", "lib/**/*.rb"]
92
+ end
93
+
94
+ RSpec::Core::RakeTask.new(:spec) do |t|
95
+ t.ruby_opts = %w(-w)
96
+ t.rspec_opts = %w(-f html -o spec.html)
97
+ end
98
+
99
+ Cucumber::Rake::Task.new(:features) do |t|
100
+ t.cucumber_opts = %w(--strict --quiet -f html -o features.html)
101
+ end
102
+
103
+ def make(*targets)
104
+ sh "make " + targets.join(" ")
105
+ end
106
+
107
+ def ctags(*files)
108
+ sh "ctags " + files.join(" ")
109
+ end
data/TODO ADDED
@@ -0,0 +1,26 @@
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
+ * Add many more requested source code examination features
25
+
26
+ Any contributions are welcome!
@@ -0,0 +1,52 @@
1
+ # ___ ____ __ ___ _________
2
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
3
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
4
+ # / __ |/ /_/ / /___/ / /| / / /
5
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
6
+ #
7
+ # This file is part of AdLint.
8
+ #
9
+ # AdLint is free software: you can redistribute it and/or modify it under the
10
+ # terms of the GNU General Public License as published by the Free Software
11
+ # Foundation, either version 3 of the License, or (at your option) any later
12
+ # version.
13
+ #
14
+ # AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
15
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License along with
19
+ # AdLint. If not, see <http://www.gnu.org/licenses/>.
20
+ #
21
+ #
22
+ # Default message catalog of c_staging examination package for ja_JP locale.
23
+ #
24
+ # *********************************
25
+ # ***** DO NOT EDIT THIS FILE *****
26
+ # *********************************
27
+ #
28
+ # To override default messages, edit `change_list' section of the traits file.
29
+ #
30
+ # [Example]
31
+ #
32
+ # % tail traits.yml
33
+ # message_traits:
34
+ # change_list:
35
+ # W9999:
36
+ # package: "c_staging"
37
+ # classes:
38
+ # - "REL:A10"
39
+ # - "PRT:B20"
40
+ # format: "Your custom message for the warning of W9999."
41
+
42
+ version: "0.2.0"
43
+
44
+ message_definition:
45
+ W2001:
46
+ classes:
47
+ - "UNC:X99"
48
+ format: "`%s' is included with an absolute pathname."
49
+ W2002:
50
+ classes:
51
+ - "UNC:X99"
52
+ format: "`%s' under the project root directory is included with #include <...> directive."
@@ -0,0 +1,52 @@
1
+ # ___ ____ __ ___ _________
2
+ # / | / _ |/ / / / | / /__ __/ Source Code Static Analyzer
3
+ # / /| | / / / / / / / |/ / / / AdLint - Advanced Lint
4
+ # / __ |/ /_/ / /___/ / /| / / /
5
+ # /_/ |_|_____/_____/_/_/ |_/ /_/ Copyright (C) 2010-2012, OGIS-RI Co.,Ltd.
6
+ #
7
+ # This file is part of AdLint.
8
+ #
9
+ # AdLint is free software: you can redistribute it and/or modify it under the
10
+ # terms of the GNU General Public License as published by the Free Software
11
+ # Foundation, either version 3 of the License, or (at your option) any later
12
+ # version.
13
+ #
14
+ # AdLint is distributed in the hope that it will be useful, but WITHOUT ANY
15
+ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
+ # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License along with
19
+ # AdLint. If not, see <http://www.gnu.org/licenses/>.
20
+ #
21
+ #
22
+ # Default message catalog of c_staging examination package for ja_JP locale.
23
+ #
24
+ # *********************************
25
+ # ***** DO NOT EDIT THIS FILE *****
26
+ # *********************************
27
+ #
28
+ # To override default messages, edit `change_list' section of the traits file.
29
+ #
30
+ # [Example]
31
+ #
32
+ # % tail traits.yml
33
+ # message_traits:
34
+ # change_list:
35
+ # W9999:
36
+ # package: "c_staging"
37
+ # classes:
38
+ # - "REL:A10"
39
+ # - "PRT:B20"
40
+ # format: "Your custom message for the warning of W9999."
41
+
42
+ version: "0.2.0"
43
+
44
+ message_definition:
45
+ W2001:
46
+ classes:
47
+ - "UNC:X99"
48
+ format: "`%s' は絶対パス指定でインクルードされています。"
49
+ W2002:
50
+ classes:
51
+ - "UNC:X99"
52
+ format: "プロジェクトルートディレクトリ内の `%s' が #include <...> ディレクティブによりインクルードされています。"
@@ -0,0 +1,25 @@
1
+ Feature: W2001
2
+
3
+ W2001 detects that an absolute pathname as argument of #include directive.
4
+
5
+ Scenario: an absolute pathname in #include "..." directive
6
+ Given a target source named "fixture.c" with:
7
+ """
8
+ #include "/dev/null" /* W2001 */
9
+ """
10
+ When I successfully run `adlint fixture.c` on noarch
11
+ Then the output should exactly match with:
12
+ | mesg | line | column |
13
+ | W2001 | 1 | 1 |
14
+
15
+ Scenario: an absolute pathname in #include <...> directive
16
+ Given a target source named "fixture.c" with:
17
+ """
18
+ #include </dev/null> /* W2001 */
19
+ """
20
+ When I successfully run `adlint fixture.c` on noarch
21
+ Then the output should exactly match with:
22
+ | mesg | line | column |
23
+ | W2001 | 1 | 1 |
24
+
25
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,33 @@
1
+ Feature: W2002
2
+
3
+ W2002 detects that a header file under the project root directory is included
4
+ as a system header.
5
+
6
+ Scenario: including as a user header
7
+ Given a target source named "fixture.c" with:
8
+ """
9
+ #include "config.h" /* OK */
10
+ """
11
+ And a target source named "config.h" with:
12
+ """
13
+ #define HAVE_STDIO_H
14
+ """
15
+ When I successfully run `adlint fixture.c` on noarch
16
+ Then the output should exactly match with:
17
+ | mesg | line | column |
18
+
19
+ Scenario: including as a system header
20
+ Given a target source named "fixture.c" with:
21
+ """
22
+ #include <config.h> /* W2002 */
23
+ """
24
+ And a target source named "config.h" with:
25
+ """
26
+ #define HAVE_STDIO_H
27
+ """
28
+ When I successfully run `adlint fixture.c` on noarch
29
+ Then the output should exactly match with:
30
+ | mesg | line | column |
31
+ | W2002 | 1 | 1 |
32
+
33
+ # vim:ts=2:sw=2:sts=2:et:
@@ -0,0 +1,18 @@
1
+ Given /^a target source named "(.*)" with:$/ do |src_name, content|
2
+ create_src_file(src_name, content)
3
+ end
4
+
5
+ When /^I successfully run `(.*)` on noarch$/ do |abbrev_cmd|
6
+ cmd, src = abbrev_cmd.split
7
+ run_adlint(cmd, src, "-t", "noarch_traits.yml")
8
+ end
9
+
10
+ Then /^the output should exactly match with:$/ do |mesg_table|
11
+ $all_output.each_line.zip(mesg_table.hashes).each do |line, row|
12
+ if row
13
+ line.should =~ /#{row[:line]}:#{row[:column]}:.*:.*:#{row[:mesg]}/
14
+ else
15
+ line.should =~ /::.*:/
16
+ end
17
+ end
18
+ end