flexpmd 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,22 +20,20 @@ Functionality is only tested on OSX, it is *not expected* to work on Windows. Yo
20
20
 
21
21
  Add the following to your rake file
22
22
 
23
- desc "Use FlexPMD to audit source code"
24
- flexpmd 'report/pmd' do |t|
23
+ flexpmd 'report' do |t|
25
24
  t.src = 'src'
26
25
  end
27
26
 
28
- desc "Use FlexCPD to detect copy pasted code"
29
27
  flexcpd 'report/cpd.xml' do |t|
30
28
  t.src = 'src'
31
29
  t.minimum_tokens = 50
32
30
  end
33
31
 
34
- desc "Use FlexMetrics to generate code metrics for this project"
35
32
  flexmetrics 'report/metrics.xml' do |t|
36
33
  t.src = 'src'
37
34
  end
38
35
 
36
+ desc "Run FlexPMD, FlexCPD, and FlexMetrics to audit the project"
39
37
  task :audit => ['report/pmd', 'report/cpd.xml', 'report/metrics.xml']
40
38
 
41
39
  Then invoke it with
@@ -43,6 +41,14 @@ Then invoke it with
43
41
  rake audit
44
42
 
45
43
  Output can be found in the `report/` directory created in the project root. This is best consumed via the relevant [Jenkins](http://jenkins-ci.org/) plugins.
44
+
45
+ ## Versioning
46
+
47
+ The version number of the gem is based on the underlying FlexPMD release number, ie 1.2, followed by a single digit expressing the gem version.
48
+
49
+ ## On the horizon
50
+
51
+ Initial release has focused on enabling report generation. As the reports are in xml, and not easy on the eye, it is intended that they are post consumed and output to the command line in a more relevant format.
46
52
 
47
53
  ## MIT License
48
54
 
data/Rakefile CHANGED
@@ -48,3 +48,8 @@ task :release do
48
48
  sh "git push origin master"
49
49
  sh "git push origin v#{FlexPMD::VERSION}"
50
50
  end
51
+
52
+ task :install do
53
+ sh "gem build flexpmd.gemspec"
54
+ sh "gem install flexpmd-#{FlexPMD::VERSION}.gem"
55
+ end
data/lib/flexpmd/base.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  module Sprout::System
2
-
2
+
3
3
  ##
4
- # Monkey patch the base system so we control the output to stderr.
4
+ # Extend the unix system so we can run tools with a 'java -jar' prefix.
5
5
  #
6
- class BaseSystem
7
-
6
+ class JavaUnixSystem < UnixSystem
7
+
8
8
  ##
9
9
  # Creates a new process, executes the command
10
10
  # and returns whatever the process wrote to stdout, or stderr.
@@ -20,20 +20,15 @@ module Sprout::System
20
20
  end
21
21
 
22
22
  if(error.size > 0)
23
- # We expect the process to write to stderror so simply print it, we don't want Sprouts
24
- # to stop executing.
25
- Sprout.stdout.puts error
23
+ # We expect the process to write to stderror so filter and print it, we don't want Rake
24
+ # to stop executing. 'WARNING' is consciously supressed as I've not seen it used as a
25
+ # prefix to anything meaningful.
26
+ #
27
+ error.each_line { |line| Sprout.stdout.puts line if line =~ /^(ERROR|INFO):/ }
26
28
  end
27
29
 
28
30
  result || error
29
31
  end
30
-
31
- end
32
-
33
- ##
34
- # Monkey patch the unix system so we can run tool with 'java -jar'.
35
- #
36
- class UnixSystem < BaseSystem
37
32
 
38
33
  ##
39
34
  # Get a process runner and execute the provided +executable+,
@@ -52,4 +47,17 @@ module Sprout::System
52
47
 
53
48
  end
54
49
 
55
- end
50
+ end
51
+
52
+ module FlexPMD
53
+ module Executable
54
+ class Base < Sprout::Executable::Base
55
+ ##
56
+ # This isn't very friendly to non unix users and needs to be addressed in future releases.
57
+ def system_execute binary, params
58
+ sys = Sprout::System::JavaUnixSystem.new
59
+ sys.execute binary, params
60
+ end
61
+ end
62
+ end
63
+ end
data/lib/flexpmd/cpd.rb CHANGED
@@ -7,7 +7,7 @@ module FlexPMD
7
7
  # (-o|--outputFile) <outputFile>
8
8
  # [(-m|--minimumTokens) <minimumTokens>]]
9
9
  #
10
- class FCPD < Sprout::Executable::Base
10
+ class FCPD < FlexPMD::Executable::Base
11
11
 
12
12
  ##
13
13
  # The source directory to recursively audit
@@ -40,7 +40,7 @@ module FlexPMD
40
40
  # The default executable target.
41
41
  #
42
42
  set :executable, :flexcpd
43
-
43
+
44
44
  end
45
45
 
46
46
  end
@@ -6,7 +6,7 @@ module FlexPMD
6
6
  # (-s|--sourceDirectory) <sourceDirectory>
7
7
  # (-o|--outputDirectory) <outputDirectory>
8
8
  #
9
- class FlexMetrics < Sprout::Executable::Base
9
+ class FlexMetrics < FlexPMD::Executable::Base
10
10
 
11
11
  ##
12
12
  # The source path to run flexpmd against.
@@ -26,7 +26,7 @@ module FlexPMD
26
26
  # The default executable target.
27
27
  #
28
28
  set :executable, :flexmetrics
29
-
29
+
30
30
  end
31
31
 
32
32
  end
data/lib/flexpmd/pmd.rb CHANGED
@@ -8,7 +8,7 @@ module FlexPMD
8
8
  #[(-r|--ruleSet) <ruleSet>]
9
9
  #[(-e|--excludePackage) <excludePackage>]
10
10
  #
11
- class FPMD < Sprout::Executable::Base
11
+ class FPMD < FlexPMD::Executable::Base
12
12
 
13
13
  ##
14
14
  # The source path to run flexpmd against.
data/lib/flexpmd.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  require 'sprout'
2
2
 
3
+ require 'flexpmd/base'
3
4
  require 'flexpmd/pmd'
4
5
  require 'flexpmd/cpd'
5
6
  require 'flexpmd/metrics'
6
- require 'flexpmd/base'
7
7
 
8
8
  module FlexPMD
9
9
  NAME = 'flexpmd'
10
10
  JAR_VERSION = '1.2'
11
- VERSION = "#{JAR_VERSION}.1"
11
+ VERSION = "#{JAR_VERSION}.2"
12
12
  MD5 = 'efd3fa459788fa3d32837628dc82e264'
13
13
  ZIP = 'http://opensource.adobe.com/svn/opensource/flexpmd/maven-repository/release/com/adobe/ac/flex-pmd/1.2/flex-pmd-all-in-one-bundle-1.2.zip'
14
14
  end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ class FlexCPDTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "A FlexCPD tool" do
7
+
8
+ setup do
9
+ @fixture = File.join fixtures, 'cpd', 'tmp'
10
+ FileUtils.makedirs @fixture
11
+ end
12
+
13
+ teardown do
14
+ remove_file @fixture
15
+ end
16
+
17
+ should "accept input" do
18
+ fcpd = FlexPMD::FCPD.new
19
+ fcpd.source_directory = @fixture
20
+ fcpd.output_file = 'report/cpd.xml'
21
+ fcpd.minimum_tokens = 100
22
+
23
+ assert_equal "-s=#{@fixture} -o=report/cpd.xml -m=100", fcpd.to_shell
24
+ end
25
+
26
+ should "accept input using aliases" do
27
+ fcpd = FlexPMD::FCPD.new
28
+ fcpd.s = @fixture
29
+ fcpd.o = 'report/cpd.xml'
30
+ fcpd.m = 100
31
+
32
+ assert_equal "-s=#{@fixture} -o=report/cpd.xml -m=100", fcpd.to_shell
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ class FlexMetricsTest < Test::Unit::TestCase
4
+ include Sprout::TestHelper
5
+
6
+ context "A FlexMetrics tool" do
7
+
8
+ setup do
9
+ @fixture = File.join fixtures, 'metrics', 'tmp'
10
+ FileUtils.makedirs @fixture
11
+ end
12
+
13
+ teardown do
14
+ remove_file @fixture
15
+ end
16
+
17
+ should "accept input" do
18
+ fcpd = FlexPMD::FlexMetrics.new
19
+ fcpd.source_directory = @fixture
20
+ fcpd.output_directory = 'report/metrics.xml'
21
+
22
+ assert_equal "-s=#{@fixture} -o=report/metrics.xml", fcpd.to_shell
23
+ end
24
+
25
+ should "accept input using aliases" do
26
+ fcpd = FlexPMD::FlexMetrics.new
27
+ fcpd.s = @fixture
28
+ fcpd.o = 'report/metrics.xml'
29
+
30
+ assert_equal "-s=#{@fixture} -o=report/metrics.xml", fcpd.to_shell
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -17,12 +17,24 @@ class FlexPMDTest < Test::Unit::TestCase
17
17
 
18
18
  should "accept input" do
19
19
  fpmd = FlexPMD::FPMD.new
20
- fpmd.src = @fixture
21
- fpmd.output = @app_desc
20
+ fpmd.source_directory = @fixture
21
+ fpmd.output_directory = 'report/pmd'
22
22
  fpmd.rule_set = Dir.pwd
23
+ fpmd.exclude_package = 'org.foo'
23
24
 
24
- assert_equal "-s=#{@fixture} -r=#{Dir.pwd}", fpmd.to_shell
25
+ assert_equal "-s=#{@fixture} -o=report/pmd -r=#{Dir.pwd} -e=org.foo", fpmd.to_shell
25
26
  end
27
+
28
+ should "accept input using aliases" do
29
+ fpmd = FlexPMD::FPMD.new
30
+ fpmd.s = @fixture
31
+ fpmd.o = 'report/pmd'
32
+ fpmd.r = Dir.pwd
33
+ fpmd.e = 'org.foo'
34
+
35
+ assert_equal "-s=#{@fixture} -o=report/pmd -r=#{Dir.pwd} -e=org.foo", fpmd.to_shell
36
+ end
37
+
26
38
  end
27
39
 
28
40
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: flexpmd
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.2.1
5
+ version: 1.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Simon Gregory
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-26 00:00:00 Z
13
+ date: 2011-06-27 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: sprout
@@ -74,6 +74,8 @@ files:
74
74
  - lib/flexpmd.rb
75
75
  - Rakefile
76
76
  - README.md
77
+ - test/unit/flexcpd_test.rb
78
+ - test/unit/flexmetrics_test.rb
77
79
  - test/unit/flexpmd_test.rb
78
80
  - test/unit/test_helper.rb
79
81
  homepage: http://projectsprouts.org
@@ -90,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
92
  requirements:
91
93
  - - ">="
92
94
  - !ruby/object:Gem::Version
93
- hash: 73980266876539591
95
+ hash: 2784567351923979262
94
96
  segments:
95
97
  - 0
96
98
  version: "0"