kolekti_cc_phpmd 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.config/cucumber.yml +11 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +39 -0
- data/COPYING +674 -0
- data/COPYING.lesser +165 -0
- data/Gemfile +4 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +11 -0
- data/gem_tasks/cucumber.rake +27 -0
- data/kolekti_cc_phpmd.gemspec +43 -0
- data/lib/kolekti/cc_phpmd.rb +6 -0
- data/lib/kolekti/cc_phpmd/collector.rb +65 -0
- data/lib/kolekti/cc_phpmd/metrics.yml +141 -0
- data/lib/kolekti/cc_phpmd/parser.rb +62 -0
- data/lib/kolekti/cc_phpmd/version.rb +3 -0
- data/scripts/docker-circle-ci +16 -0
- metadata +211 -0
data/COPYING.lesser
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
2
|
+
Version 3, 29 June 2007
|
3
|
+
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
6
|
+
of this license document, but changing it is not allowed.
|
7
|
+
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# KolektiCCPHPMD
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/mezuro/kolekti_cc_phpmd.png)](https://codeclimate.com/github/mezuro/kolekti_cc_phpmd)
|
4
|
+
|
5
|
+
Generic parser for Analizo static code metrics collector.
|
6
|
+
|
7
|
+
## Contributing
|
8
|
+
|
9
|
+
Please, have a look the wiki pages about development workflow and code standards:
|
10
|
+
|
11
|
+
* https://github.com/mezuro/mezuro/wiki/Development-workflow
|
12
|
+
* https://github.com/mezuro/mezuro/wiki/Standards
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'kolekti_cc_phpmd'
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install kolekti_cc_phpmd
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
Just register it into Kolekti with
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'kolekti'
|
34
|
+
require 'kolekti_cc_phpmd'
|
35
|
+
|
36
|
+
Kolekti.register_collector(Kolekti::CcPhpMd::Collector.new)
|
37
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
# Copied from https://github.com/cucumber/cucumber-ruby/blob/master/Rakefile#L6
|
7
|
+
$:.unshift(File.dirname(__FILE__) + '/lib')
|
8
|
+
Dir['gem_tasks/**/*.rake'].each { |rake| load rake }
|
9
|
+
|
10
|
+
task :default => [:spec, :cucumber]
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "kolekti_cc_phpmd"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
machine:
|
2
|
+
services:
|
3
|
+
- docker
|
4
|
+
|
5
|
+
dependencies:
|
6
|
+
pre:
|
7
|
+
# Workaround: replace docker command with one that ignores the --rm and --cap-drop options
|
8
|
+
- sudo cp scripts/docker-circle-ci /usr/local/bin/docker
|
9
|
+
- sudo chmod 755 /usr/local/bin/docker
|
10
|
+
- docker pull codeclimate/codeclimate-phpmd:latest
|
11
|
+
- gem install bundler
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Copied from https://github.com/cucumber/cucumber-ruby/blob/master/gem_tasks/cucumber.rake
|
2
|
+
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
require 'cucumber/platform'
|
5
|
+
|
6
|
+
class Cucumber::Rake::Task
|
7
|
+
def set_profile_for_current_ruby
|
8
|
+
self.profile = if Cucumber::JRUBY
|
9
|
+
Cucumber::WINDOWS ? 'jruby_win' : 'jruby'
|
10
|
+
elsif Cucumber::WINDOWS_MRI
|
11
|
+
'windows_mri'
|
12
|
+
elsif Cucumber::RUBY_1_9
|
13
|
+
'ruby_1_9'
|
14
|
+
elsif Cucumber::RUBY_2_0
|
15
|
+
'ruby_2_0'
|
16
|
+
elsif Cucumber::RUBY_2_1
|
17
|
+
'ruby_2_1'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
23
|
+
t.fork = true
|
24
|
+
t.set_profile_for_current_ruby
|
25
|
+
end
|
26
|
+
|
27
|
+
task :cucumber => :features
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
version = File.read(File.expand_path("../../VERSION", __dir__)).strip
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "kolekti_cc_phpmd"
|
8
|
+
spec.version = version
|
9
|
+
spec.authors = ["Daniel Miranda",
|
10
|
+
"Diego Araújo",
|
11
|
+
"Eduardo Araújo",
|
12
|
+
"Rafael Reggiani Manzo"]
|
13
|
+
spec.email = ["danielkza2@gmail.com",
|
14
|
+
"diegoamc90@gmail.com",
|
15
|
+
"duduktamg@hotmail.com",
|
16
|
+
"rr.manzo@protonmail.com"]
|
17
|
+
|
18
|
+
spec.summary = %q{Metric collecting support for PHP that servers Kolekti.}
|
19
|
+
spec.homepage = "https://gitlab.com/mezuro/mezuro/tree/master/kalibro/kolekti_cc_phpmd"
|
20
|
+
|
21
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
22
|
+
# delete this section to allow pushing this gem to any host.
|
23
|
+
unless spec.respond_to?(:metadata)
|
24
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_dependency "codeclimate", "~>0.35.0"
|
33
|
+
spec.add_dependency "kolekti", "~> 1.0"
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "cucumber", "~> 2.1.0"
|
39
|
+
spec.add_development_dependency "simplecov"
|
40
|
+
spec.add_development_dependency "factory_girl", "~> 4.5.0"
|
41
|
+
spec.add_development_dependency "codeclimate-test-reporter", '< 1.0.0'
|
42
|
+
spec.add_development_dependency "byebug"
|
43
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'kolekti/cc_phpmd/parser'
|
2
|
+
require 'kolekti/collector'
|
3
|
+
require 'cc/cli'
|
4
|
+
require 'cc/analyzer'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
module Kolekti
|
8
|
+
module CcPhpMd
|
9
|
+
class Collector < Kolekti::Collector
|
10
|
+
def self.create_cc_dir
|
11
|
+
old_umask = File.umask
|
12
|
+
begin
|
13
|
+
File.umask(022)
|
14
|
+
FileUtils.mkdir_p('/tmp/cc', mode: 0755)
|
15
|
+
ensure
|
16
|
+
File.umask(old_umask)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.available?
|
21
|
+
# Make sure the CodeClimate temporary directory is created world-readable,
|
22
|
+
# otherwise it may be possible for the container not to be able to properly
|
23
|
+
# access it.
|
24
|
+
|
25
|
+
# It has to be done before any CC invocation or Docker will create the directory
|
26
|
+
# owned by root (that behavior is fortunately deprecated starting with Docker 1.9)
|
27
|
+
create_cc_dir
|
28
|
+
|
29
|
+
system('docker inspect codeclimate/codeclimate-phpmd', [:out, :err] => '/dev/null') ? true : false
|
30
|
+
end
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
supported_metrics = parse_supported_metrics(
|
34
|
+
File.expand_path("../metrics.yml", __FILE__),
|
35
|
+
'CodeClimate PHPMD', [:PHP])
|
36
|
+
super('CodeClimate PHPMD', 'PHP Mess Detector', supported_metrics)
|
37
|
+
|
38
|
+
self.class.create_cc_dir
|
39
|
+
end
|
40
|
+
|
41
|
+
def collect_metrics(code_directory, wanted_metric_configurations, persistence_strategy)
|
42
|
+
FileUtils.chmod_R "a+rX", code_directory
|
43
|
+
engine_registry = CC::Analyzer::EngineRegistry.new
|
44
|
+
parser = Kolekti::CcPhpMd::Parser.new(self, wanted_metric_configurations, persistence_strategy)
|
45
|
+
|
46
|
+
Dir.chdir(code_directory) do
|
47
|
+
runner = CC::Analyzer::EnginesRunner.new(engine_registry, parser, code_directory, @@config, [])
|
48
|
+
runner.run
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def clean(code_directory, wanted_metric_configurations); end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self.config
|
57
|
+
config = CC::Yaml::Nodes::Root.new
|
58
|
+
config["engines"] = CC::Yaml::Nodes::EngineList.new(config).with_value({})
|
59
|
+
config.engines["phpmd"] = CC::Yaml::Nodes::Engine.new(config.engines).with_value("enabled" => true)
|
60
|
+
config
|
61
|
+
end
|
62
|
+
@@config = self.config
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
:metrics:
|
2
|
+
:baf:
|
3
|
+
:name: CleanCode/BooleanArgumentFlag
|
4
|
+
:type: HotspotMetricSnapshot
|
5
|
+
:description: A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
|
6
|
+
:ee:
|
7
|
+
:name: CleanCode/ElseExpression
|
8
|
+
:type: HotspotMetricSnapshot
|
9
|
+
:description: An if expression with an else branch is never necessary. You can rewrite the conditions in a way that the else is not necessary and the code becomes simpler to read. To achieve this use early return statements. To achieve this you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
|
10
|
+
:sa:
|
11
|
+
:name: CleanCode/StaticAccess
|
12
|
+
:type: HotspotMetricSnapshot
|
13
|
+
:description: Static acccess causes inexchangable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
|
14
|
+
:cccn:
|
15
|
+
:name: Controversial/CamelCaseClassName
|
16
|
+
:type: HotspotMetricSnapshot
|
17
|
+
:description: It is considered best practice to use the CamelCase notation to name classes.
|
18
|
+
:ccm:
|
19
|
+
:name: Controversial/CamelCaseMethodName
|
20
|
+
:type: HotspotMetricSnapshot
|
21
|
+
:description: It is considered best practice to use the camelCase notation to name methods.
|
22
|
+
:ccpan:
|
23
|
+
:name: Controversial/CamelCaseParameterName
|
24
|
+
:type: HotspotMetricSnapshot
|
25
|
+
:description: It is considered best practice to use the camelCase notation to name parameters.
|
26
|
+
:ccprn:
|
27
|
+
:name: Controversial/CamelCasePropertyName
|
28
|
+
:type: HotspotMetricSnapshot
|
29
|
+
:description: It is considered best practice to use the camelCase notation to name attributes.
|
30
|
+
:ccvn:
|
31
|
+
:name: Controversial/CamelCaseVariableName
|
32
|
+
:type: HotspotMetricSnapshot
|
33
|
+
:description: It is considered best practice to use the camelCase notation to name variables.
|
34
|
+
:sg:
|
35
|
+
:name: Controversial/Superglobals
|
36
|
+
:type: HotspotMetricSnapshot
|
37
|
+
:description: Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
|
38
|
+
:cc:
|
39
|
+
:name: CyclomaticComplexity
|
40
|
+
:type: HotspotMetricSnapshot
|
41
|
+
:description: Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
|
42
|
+
:cbo:
|
43
|
+
:name: Design/CouplingBetweenObjects
|
44
|
+
:type: HotspotMetricSnapshot
|
45
|
+
:description: A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
|
46
|
+
:doi:
|
47
|
+
:name: Design/DepthOfInheritance
|
48
|
+
:type: HotspotMetricSnapshot
|
49
|
+
:description: A class with many parents is an indicator for an unbalanced and wrong class hierarchy. You should consider to refactor this class hierarchy.
|
50
|
+
:eex:
|
51
|
+
:name: Design/EvalExpression
|
52
|
+
:type: HotspotMetricSnapshot
|
53
|
+
:description: An eval-expression is untestable, a security risk and bad practice. Therefore it should be avoided. Consider to replace the eval-expression with regular code.
|
54
|
+
:exe:
|
55
|
+
:name: Design/ExitExpression
|
56
|
+
:type: HotspotMetricSnapshot
|
57
|
+
:description: An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.
|
58
|
+
:gs:
|
59
|
+
:name: Design/GotoStatement
|
60
|
+
:type: HotspotMetricSnapshot
|
61
|
+
:description: Goto makes code harder to read and it is nearly impossible to understand the control flow of an application that uses this language construct. Therefore it should be avoided. Consider to replace Goto with regular control structures and separate methods/function, which are easier to read.
|
62
|
+
:lc:
|
63
|
+
:name: Design/LongClass
|
64
|
+
:type: HotspotMetricSnapshot
|
65
|
+
:description: Long Class files are indications that the class may be trying to do too much. Try to break it down, and reduce the size to something manageable.
|
66
|
+
:lm:
|
67
|
+
:name: Design/LongMethod
|
68
|
+
:type: HotspotMetricSnapshot
|
69
|
+
:description: Violations of this rule usually indicate that the method is doing too much. Try to reduce the method size by creating helper methods and removing any copy/pasted code.
|
70
|
+
:lpl:
|
71
|
+
:name: Design/LongParameterList
|
72
|
+
:type: HotspotMetricSnapshot
|
73
|
+
:description: Long parameter lists can indicate that a new object should be created to wrap the numerous parameters. Basically, try to group the parameters together.
|
74
|
+
:npath:
|
75
|
+
:name: Design/NpathComplexity
|
76
|
+
:type: HotspotMetricSnapshot
|
77
|
+
:description: The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
|
78
|
+
:noc:
|
79
|
+
:name: Design/NumberOfChildren
|
80
|
+
:type: HotspotMetricSnapshot
|
81
|
+
:description: A class with an excessive number of children is an indicator for an unbalanced class hierarchy. You should consider to refactor this class hierarchy.
|
82
|
+
:tmf:
|
83
|
+
:name: Design/TooManyFields
|
84
|
+
:type: HotspotMetricSnapshot
|
85
|
+
:description: Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
|
86
|
+
:tmm:
|
87
|
+
:name: Design/TooManyMethods
|
88
|
+
:type: HotspotMetricSnapshot
|
89
|
+
:description: A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
|
90
|
+
:tmpm:
|
91
|
+
:name: Design/TooManyPublicMethods
|
92
|
+
:type: HotspotMetricSnapshot
|
93
|
+
:description: A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
|
94
|
+
:wmc:
|
95
|
+
:name: Design/WeightedMethodCount
|
96
|
+
:type: HotspotMetricSnapshot
|
97
|
+
:description: The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.
|
98
|
+
:epc:
|
99
|
+
:name: ExcessivePublicCount
|
100
|
+
:type: HotspotMetricSnapshot
|
101
|
+
:description: A large number of public methods and attributes declared in a class can indicate the class may need to be broken up as increased effort will be required to thoroughly test it.
|
102
|
+
:bgmn:
|
103
|
+
:name: Naming/BooleanGetMethodName
|
104
|
+
:type: HotspotMetricSnapshot
|
105
|
+
:description: Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.
|
106
|
+
:cnc:
|
107
|
+
:name: Naming/ConstantNamingConventions
|
108
|
+
:type: HotspotMetricSnapshot
|
109
|
+
:description: Class/Interface constant nanmes should always be defined in uppercase.
|
110
|
+
:cwnaec:
|
111
|
+
:name: Naming/ConstructorWithNameAsEnclosingClass
|
112
|
+
:type: HotspotMetricSnapshot
|
113
|
+
:description: A constructor method should not have the same name as the enclosing class, consider to use the PHP 5 __construct method.
|
114
|
+
:lv:
|
115
|
+
:name: Naming/LongVariable
|
116
|
+
:type: HotspotMetricSnapshot
|
117
|
+
:description: Detects when a field, formal or local variable is declared with a long name.
|
118
|
+
:smn:
|
119
|
+
:name: Naming/ShortMethodName
|
120
|
+
:type: HotspotMetricSnapshot
|
121
|
+
:description: Detects when very short method names are used.
|
122
|
+
:sv:
|
123
|
+
:name: Naming/ShortVariable
|
124
|
+
:type: HotspotMetricSnapshot
|
125
|
+
:description: Detects when a field, local, or parameter has a very short name.
|
126
|
+
:ufp:
|
127
|
+
:name: UnusedFormalParameter
|
128
|
+
:type: HotspotMetricSnapshot
|
129
|
+
:description: Avoid passing parameters to methods or constructors and then not using those parameters.
|
130
|
+
:ulv:
|
131
|
+
:name: UnusedLocalVariable
|
132
|
+
:type: HotspotMetricSnapshot
|
133
|
+
:description: Detects when a local variable is declared and/or assigned, but not used.
|
134
|
+
:upf:
|
135
|
+
:name: UnusedPrivateField
|
136
|
+
:type: HotspotMetricSnapshot
|
137
|
+
:description: Detects when a private field is declared and/or assigned a value, but not used.
|
138
|
+
:upm:
|
139
|
+
:name: UnusedPrivateMethod
|
140
|
+
:type: HotspotMetricSnapshot
|
141
|
+
:description: Unused Private Method detects when a private method is declared but is unused.
|