This PR covers three main things. In order of importance:
Shotgun Surgery
Shotgun surgery is detected in this case by keeping track of both how many methods a given method calls, as well as how many actual classes a method calls. The reasoning behind this is that if, in order to change a method's functionality, we need to change everything that method may use, then a method that uses, say, five or six or more separate files to define itself is a method that is very difficult to modify in a centralized way. This article has more details and forms the basis for me using this method.
Currently, we check for methods that call at least 5 other classes and at least ten other methods. These are more or less arbitrary figures and subject to change. Currently the method is incapable of finding calls to methods within the same class as the method.
Feature Envy
I spent some time trying to clean up the behavior of the feature envy smell. In bullet point form:
Feature envy now also checks attributes calls and sums attribute calls + method calls together. If ClassA uses ClassB.n a lot, that will show up.
Feature envy no longer applies for interfaces.
Feature envy no longer counts the main method either.
Smell Tester Class
This came while writing the test file for Shotgun Surgery. I already had a macro defined in FeatureEnvyTest for returning whether or not a given class was detected in the CPG, and expanded on that a bit and made FeatureEnvyTest and ShotgunSurgeryTest both inherit from an abstract 'SmellTester' class.
This PR covers three main things. In order of importance:
Shotgun Surgery
Shotgun surgery is detected in this case by keeping track of both how many methods a given method calls, as well as how many actual classes a method calls. The reasoning behind this is that if, in order to change a method's functionality, we need to change everything that method may use, then a method that uses, say, five or six or more separate files to define itself is a method that is very difficult to modify in a centralized way. This article has more details and forms the basis for me using this method. Currently, we check for methods that call at least 5 other classes and at least ten other methods. These are more or less arbitrary figures and subject to change. Currently the method is incapable of finding calls to methods within the same class as the method.
Feature Envy
I spent some time trying to clean up the behavior of the feature envy smell. In bullet point form:
Smell Tester Class
This came while writing the test file for Shotgun Surgery. I already had a macro defined in FeatureEnvyTest for returning whether or not a given class was detected in the CPG, and expanded on that a bit and made FeatureEnvyTest and ShotgunSurgeryTest both inherit from an abstract 'SmellTester' class.