nitc :: FeatureEnvy
nitc :: FeatureEnvy :: _bad_methods
nitc :: FeatureEnvy :: bad_methods
nitc :: FeatureEnvy :: bad_methods=
nitc :: FeatureEnvy :: defaultinit
nitc $ FeatureEnvy :: SELF
Type of this instance, automatically specialized in every classnitc $ FeatureEnvy :: collect
Collection methodnitc :: FeatureEnvy :: _bad_methods
nitc :: BadConception :: _filter
nitc :: BadConception :: _model
nitc :: BadConception :: _phase
nitc :: BadConception :: _score
nitc :: FeatureEnvy :: bad_methods
nitc :: FeatureEnvy :: bad_methods=
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: BadConception :: collect
Collection methodcore :: Object :: defaultinit
nitc :: FeatureEnvy :: 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 FeatureEnvy
super BadConception
var bad_methods = new Array[MMethodDef]
redef fun name do return "FEM"
redef fun desc do return "Feature envy"
redef fun collect(mclassdef, model_builder): Bool do
var mmethoddefs = call_analyze_methods(mclassdef,model_builder, filter)
for mmethoddef in mmethoddefs do
var max_class_call = mmethoddef.class_call.max
# Check if the class with the maximum call is >= auto-call and the maximum call class is != of this class
if mmethoddef.class_call[max_class_call] <= mmethoddef.total_self_call or max_class_call.mclass.full_name == mclassdef.mclass.full_name 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}:")
if self.bad_methods.not_empty then
print " Affected method(s):"
for method in self.bad_methods do
var max_class_call = method.class_call.max
if max_class_call != null then
# Check if the type of max call class is generique
if max_class_call.mclass.mclass_type isa MGenericType and not phase.toolcontext.opt_move_generics.value then
print " -{method.name}({method.msignature.mparameters.join(", ")}) {method.total_self_call}/{method.class_call[max_class_call]}"
else
print " -{method.name}({method.msignature.mparameters.join(", ")}) {method.total_self_call}/{method.class_call[max_class_call]} move to {max_class_call}"
end
end
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:257,1--300,3