nitc :: LongMethod
nitc :: LongMethod :: _bad_methods
nitc :: LongMethod :: bad_methods
nitc :: LongMethod :: bad_methods=
nitc :: LongMethod :: defaultinit
nitc $ LongMethod :: SELF
Type of this instance, automatically specialized in every classnitc $ LongMethod :: collect
Collection methodnitc :: LongMethod :: _bad_methods
nitc :: BadConception :: _filter
nitc :: BadConception :: _model
nitc :: BadConception :: _phase
nitc :: BadConception :: _score
nitc :: LongMethod :: bad_methods
nitc :: LongMethod :: bad_methods=
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: BadConception :: collect
Collection methodcore :: Object :: defaultinit
nitc :: LongMethod :: 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 LongMethod
super BadConception
var bad_methods = new Array[MMethodDef]
redef fun name do return "LONGMETH"
redef fun desc do return "Long method"
redef fun collect(mclassdef, model_builder): Bool do
var mmethoddefs = call_analyze_methods(mclassdef,model_builder, filter)
var threshold_value = phase.average_number_of_lines.to_i
# Get the threshold value from the toolcontext command
if phase.toolcontext.opt_long_method_threshold.value != 0 then threshold_value = phase.toolcontext.opt_long_method_threshold.value
for mmethoddef in mmethoddefs do
if mmethoddef.line_number <= threshold_value then continue
self.bad_methods.add(mmethoddef)
end
self.score_rate
return self.bad_methods.not_empty
end
redef fun print_result do
print phase.toolcontext.format_h2("{desc}: Average {phase.average_number_of_lines.to_i} lines")
if self.bad_methods.not_empty then
print " Affected method(s):"
for method in self.bad_methods do
print " -{method.name} has {method.line_number} lines"
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:302,1--339,3