nitc :: LongParameterList :: bad_methods
nitc :: LongParameterList :: defaultinit
nitc $ LongParameterList :: SELF
Type of this instance, automatically specialized in every classnitc $ LongParameterList :: collect
Collection methodnitc :: BadConception :: _filter
nitc :: BadConception :: _model
nitc :: BadConception :: _phase
nitc :: BadConception :: _score
nitc :: LongParameterList :: bad_methods
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: BadConception :: collect
Collection methodcore :: Object :: defaultinit
nitc :: LongParameterList :: defaultinit
nitc :: BadConception :: defaultinit
nitc :: BadConception :: filter
nitc :: BadConception :: filter=
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
nitc :: BadConception :: model
nitc :: BadConception :: model=
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).nitc :: BadConception :: phase
nitc :: BadConception :: phase=
nitc :: BadConception :: score
nitc :: BadConception :: score=
class LongParameterList
super BadConception
var bad_methods = new Array[MMethodDef]
redef fun name do return "LONGPL"
redef fun desc do return "Long parameter list"
redef fun collect(mclassdef, model_builder): Bool do
for meth in mclassdef.collect_intro_and_redef_mpropdefs(filter) do
var threshold_value = 4
# Get the threshold value from the toolcontext command
if phase.toolcontext.opt_long_params_threshold.value != 0 then threshold_value = phase.toolcontext.opt_long_params_threshold.value
# Check if the property is a method definition
if not meth isa MMethodDef then continue
# Check if method has a signature
if meth.msignature == null then continue
if meth.msignature.mparameters.length <= threshold_value then continue
self.bad_methods.add(meth)
end
self.score_rate
return self.bad_methods.not_empty
end
redef fun print_result do
print phase.toolcontext.format_h2("{desc}:")
if self.bad_methods.not_empty then
print " Affected method(s):"
for method in self.bad_methods do
print " -{method.name} has {method.msignature.mparameters.length} parameters"
end
end
end
redef fun score_rate do
if self.bad_methods.not_empty then
self.score = self.bad_methods.length.to_f/ phase.average_number_of_method
end
end
end
src/metrics/codesmells_metrics.nit:216,1--255,3