Method and apparatus for finding long methods in code
AssigneeDevFactory Innovations FZ-LLC
InventorAditya T. Kadam
Life of this patent
Estimating the term…
Abstract
A method and apparatus are disclosed for finding overlong source code segments (e.g., methods) by evaluating input source code segments for a plurality of predetermined code metric values in order to identify candidate source code segments (e.g., non-autogenerated methods) which do not meet a first code metric value and to assess each candidate source code segment against a second code metric value to identify different sets of candidate source code segments (e.g., test methods and normal methods) so that each set of candidate source code segments may be assessed against a tailored set of code length thresholds to identify any overlong source code segment having a code length which meets or exceeds at least two of the tailored set of code length thresholds.
Claims25
A method performed by a device having a processor and memory for enhancing operable functionality of a software program, comprising:
- receiving, by the device, a plurality of input source code segments from the software program submitted by a developer;
- evaluating, by the device, each of the plurality of input source code segments for a plurality of predetermined code metric values;
- identifying, by the device, one or more candidate source code segments from the plurality of input source code segments by removing one or more code segments that meet a first code metric value;
- (a) assessing, by the device, each of the one or more candidate source code segments against a second code metric value to identify a first set of candidate source code segments that contain the second code metric value and a second set of candidate code segments that do not contain the second predetermined code metric value;
- (b) assessing the first set of candidate source code segments against a first tailored set of code length thresholds to identify any overlong source code segment in the first set of candidate source code segments having a code length which meets or exceeds at least two of the first tailored set of code length thresholds;
- (c) assessing the second set of candidate source code segments against a second tailored set of code length thresholds which is different from the first tailored set of code length thresholds to identify any overlong source code segment in the second set of candidate source code segments having a code length which meets or exceeds at least two of the second tailored set of code length thresholds;
- and
- providing refactoring recommendations of the software program in accordance with the plurality of assessments (a), (b), and (c).
A computer program product comprising at least one computer readable storage medium having stored thereon executable instructions and data which, when executed by at least one processing device, cause the at least one processing device to:
- receive a plurality of input source code segments from the software program submitted by a developer;
- evaluate each of the plurality of input source code segments for a plurality of predetermined code metric values;
- identify one or more candidate source code segments from the plurality of input source code segments by removing one or more code segments that meet a first code metric value;
- (a) assess each of the one or more candidate source code segments against a second code metric value to identify a first set of candidate source code segments that contain the second code metric value and a second set of candidate code segments that do not contain the second predetermined code metric value;
- (b) assess the first set of candidate source code segments against a first tailored set of code length thresholds to identify any overlong source code segment in the first set of candidate source code segments having a code length which meets or exceeds at least two of the first tailored set of code length thresholds;
- (c) assess the second set of candidate source code segments against a second tailored set of code length thresholds which is different from the first tailored set of code length thresholds to identify any overlong source code segment in the second set of candidate source code segments having a code length which meets or exceeds at least two of the second tailored set of code length thresholds;
- and
- provide refactoring recommendations of the software program in accordance with the plurality of assessments (a), (b), and (c).
A system comprising:
- one or more processors;
- a memory coupled to at least one of the processors;
- and
- a set of instructions stored in the memory and executed by at least one of the processors to enhance operable functionality of a software program by identifying overlong source code segments, wherein the set of instructions are executable to perform actions of:
- receiving a plurality of input source code segments from the software program submitted by a developer;
- evaluating each of the plurality of input source code segments for a plurality of predetermined code metric values;
- identifying one or more candidate source code segments from the plurality of input source code segments by removing one or more code segments that meet a first code metric value;
- (a) assessing each of the one or more candidate source code segments against a second code metric value to identify a first set of candidate source code segments that contain the second code metric value and a second set of candidate code segments that do not contain the second predetermined code metric value;
- (b) assessing the first set of candidate source code segments against a first tailored set of code length thresholds to identify any overlong source code segment in the first set of candidate source code segments having a code length which meets or exceeds at least two of the first tailored set of code length thresholds;
- (c) assessing the second set of candidate source code segments against a second tailored set of code length thresholds which is different from the first tailored set of code length thresholds to identify any overlong source code segment in the second set of candidate source code segments having a code length which meets or exceeds at least two of the second tailored set of code length thresholds;
- reporting a prioritized list of any overlong source code segments that meets or exceeds at least two of the first tailored set of code length thresholds or at least two of the second tailored set of code length thresholds for recommended refactoring treatment by the developer;
- and
- providing refactoring recommendations of the software program in accordance with the plurality of assessments (a), (b), and (c).
Dependencies are inferred from the claim text.