diff --git a/docs/Design/SoftArchitecture/MG.tex b/docs/Design/SoftArchitecture/MG.tex index 659e4fc0..368972bc 100644 --- a/docs/Design/SoftArchitecture/MG.tex +++ b/docs/Design/SoftArchitecture/MG.tex @@ -191,10 +191,15 @@ \section{Module Hierarchy} \label{SecMH} actually be implemented. \begin{description} -\item [\refstepcounter{mnum} \mthemnum \label{mHH}:] Hardware-Hiding Module +\item [\refstepcounter{mnum} \mthemnum \label{mSmell}:] Smell Module +\item [\refstepcounter{mnum} \mthemnum \label{mBR}:] BaseRefactorer Module +\item [\refstepcounter{mnum} \mthemnum \label{mMIMR}:] MakeStaticRefactorer Module +\item [\refstepcounter{mnum} \mthemnum \label{mSCLR}:] UseListAccumulationRefactorer Module \item [\refstepcounter{mnum} \mthemnum \label{mUGENR}:] UseAGeneratorRefactorer Module \item [\refstepcounter{mnum} \mthemnum \label{mCRC}:] CacheRepeatedCallsRefactorer Module \item [\refstepcounter{mnum} \mthemnum \label{mLEC}:] LongElementChainRefactorer Module +\item [\refstepcounter{mnum} \mthemnum \label{mPyA}:] Pylint Analyzer Module +\item [\refstepcounter{mnum} \mthemnum \label{mTest}:] Testing Functionality Module \end{description} @@ -205,10 +210,15 @@ \section{Module Hierarchy} \label{SecMH} \textbf{Level 1} & \textbf{Level 2}\\ \midrule -{Hardware-Hiding Module} & ~ \\ +{Hardware-Hiding Module} & None \\ \midrule -\multirow{7}{0.3\textwidth}{Behaviour-Hiding Module} & CacheRepeatedCallsRefactorer Module\\ +\multirow{7}{0.3\textwidth}{Behaviour-Hiding Module} & Smell Module\\ +& BaseRefactorer Module\\ +& CacheRepeatedCallsRefactorer Module\\ +& MakeStaticRefactorer Module\\ +& UseListAccumulationRefactorer Module\\ +& ?\\ & UseAGeneratorRefactorer Module\\ & ?\\ & LongElementChainRefactorer Module\\ @@ -218,9 +228,9 @@ \section{Module Hierarchy} \label{SecMH} & ?\\ \midrule -\multirow{3}{0.3\textwidth}{Software Decision Module} & {?}\\ -& ?\\ -& ?\\ +\multirow{3}{0.3\textwidth}{Software Decision Module} & Pylint Analyzer Module\\ +& Testing Functionality Module\\ +& Measurements Module\\ \bottomrule \end{tabular} @@ -257,53 +267,48 @@ \section{Module Decomposition} \label{SecMD} (\emph{--}) is shown, this means that the module is not a leaf and will not have to be implemented. -\subsection{Hardware Hiding Modules (\mref{mHH})} +\subsection{Hardware Hiding Modules} -\begin{description} -\item[Secrets:]The data structure and algorithm used to implement the virtual - hardware. -\item[Services:]Serves as a virtual hardware used by the rest of the - system. This module provides the interface between the hardware and the - software. So, the system can use it to display outputs or to accept inputs. -\item[Implemented By:] OS -\end{description} +This system has no hardware components. \subsection{Behaviour-Hiding Module} +\subsubsection{Smell Module (\mref{mSmell})} + \begin{description} -\item[Secrets:]The contents of the required behaviours. -\item[Services:]Includes programs that provide externally visible behaviour of - the system as specified in the software requirements specification (SRS) - documents. This module serves as a communication layer between the - hardware-hiding module and the software decision module. The programs in this - module will need to change if there are changes in the SRS. -\item[Implemented By:] -- +\item[Secrets:] Data structure of a code smell. +\item[Services:] Provides an interface for other modules to access information of a smell object. +\item[Implemented By:] EcoOptimizer +\item[Type of Module:] Abstract Data Type \end{description} -\subsubsection{Long Element Chain Module (\mref{mLEC})} +\subsubsection{Base Refactorer Module (\mref{mBR})} % [Record, Library, Abstract Object, or Abstract Data Type] \begin{description} - \item[Secrets:] How to parse a given code file to its AST representation, traverse the - AST tree to identify dictionary assignments, analyze the structure of nested dictionaries, - and flatten them. Additionally, it identifies all access calls associated with these dictionaries - in the source code and determines how to update them to reflect the new flattened structure. - \item[Services:] Detects nested dictionaries in the source code using AST parsing, simplifies their - structure by flattening them, and updates all associated access calls throughout the file. This improves - code readability, reduces complexity, and ensures correctness while maintaining the program's intended behavior. + \item[Secrets:] None + \item[Services:] Offers an interface for other refactoring modules to implement. \item[Implemented By:] EcoOptimizer \end{description} -\subsubsection{Input Format Module (\mref{mInput})} +\subsubsection{MakeStaticRefactorer Module (\mref{mMIMR})} + +% [Record, Library, Abstract Object, or Abstract Data Type] +\begin{description} +\item[Secrets:] How to parse a given code file to its AST representation, how to traverse the AST tree, how to modify specific nodes in the AST tree, how to convert the modified AST tree back to source code and write it to an output file. +\item[Services:] Refactors the \textit{\textbf{Member Ignoring Method (MIM)}} smell in a provided code file to improve energy efficiency. +\item[Implemented By:] EcoOptimizer +\end{description} + +\subsubsection{UseListAccumulationRefactorer Module (\mref{mSCLR})} + +% [Record, Library, Abstract Object, or Abstract Data Type] \begin{description} -\item[Secrets:]The format and structure of the input data. -\item[Services:]Converts the input data into the data structure used by the - input parameters module. -\item[Implemented By:] [Your Program Name Here] -\item[Type of Module:] [Record, Library, Abstract Object, or Abstract Data Type] - [Information to include for leaf modules in the decomposition by secrets tree.] +\item[Secrets:] How to parse a given code file into its AST representation, how to traverse the AST tree, how to find the initializing variable of the string concatenation, how to find the scope of the concatenation, how to modify the given code file in plain text and write it back to an output file. +\item[Services:] Refactors the \textbf{\textit{String Concatenation Inside Loop (SCL)}} smell in a provided code file to improve energy efficiency. +\item[Implemented By:] EcoOptimizer \end{description} \subsubsection{UseAGeneratorRefactorer Module (\mref{mUGENR})} @@ -320,8 +325,20 @@ \subsubsection{CacheRepeatedCallsRefactorer Module (\mref{mCRC})} \item[Implemented By:] EcoOptimizer \end{description} -\subsubsection{Etc.} +\subsubsection{Long Element Chain Module (\mref{mLEC})} +% [Record, Library, Abstract Object, or Abstract Data Type] + +\begin{description} + \item[Secrets:] How to parse a given code file to its AST representation, traverse the + AST tree to identify dictionary assignments, analyze the structure of nested dictionaries, + and flatten them. Additionally, it identifies all access calls associated with these dictionaries + in the source code and determines how to update them to reflect the new flattened structure. + \item[Services:] Detects nested dictionaries in the source code using AST parsing, simplifies their + structure by flattening them, and updates all associated access calls throughout the file. This improves + code readability, reduces complexity, and ensures correctness while maintaining the program's intended behavior. + \item[Implemented By:] EcoOptimizer +\end{description} \subsection{Software Decision Module} @@ -336,7 +353,7 @@ \subsection{Software Decision Module} \item[Implemented By:] -- \end{description} -\subsubsection{Pylint Analyzer Module} +\subsubsection{Pylint Analyzer Module (\mref{mPyA})} \begin{description} \item[Secrets:] The internal design and execution of static code analysis using Pylint and AST parsing, including custom detection and structuring of smells. These details are hidden from external modules. @@ -349,6 +366,16 @@ \subsubsection{Pylint Analyzer Module} \item[Implemented By:] \texttt{EcoOptimizer} \end{description} +\subsubsection{Testing Functionality Module (\mref{mTest})} + +% [Record, Library, Abstract Object, or Abstract Data Type] + +\begin{description} + \item[Secrets:] Runs testing suites in a subprocess. + \item[Services:] Checks whether the functionality of a given source code has changed. + \item[Implemented By:] EcoOptimizer +\end{description} + \section{Traceability Matrix} \label{SecTM} @@ -428,7 +455,7 @@ \section{Use Hierarchy Between Modules} \label{SecUse} \begin{figure}[H] \centering -%\includegraphics[width=0.7\textwidth]{UsesHierarchy.png} +\includegraphics[width=\textwidth]{../../Images/use_hierarchy_modules.png} \caption{Use hierarchy among modules} \label{FigUH} \end{figure} diff --git a/docs/Design/SoftDetailedDes/MIS.tex b/docs/Design/SoftDetailedDes/MIS.tex index 62d17da9..2b0e9cd5 100644 --- a/docs/Design/SoftDetailedDes/MIS.tex +++ b/docs/Design/SoftDetailedDes/MIS.tex @@ -226,6 +226,334 @@ \subsubsection{Local Functions} explicitly. Even if they are implemented, they are not exported; they only have local scope.} +\newpage + +\section{MIS of Base Refactorer} \label{mis:baseR} + +\texttt{BaseRefactorer} + +\subsection{Module} + +The interface that all refactorers of this system will inherit from. + +\subsection{Uses} + +None + +\subsection{Syntax} +\noindent +\textbf{Exported Constants}: None + +\noindent +\textbf{Exported Access Programs}: + +\begin{tabularx}{\linewidth}{|l|>{\raggedright\arraybackslash}X|l|l|} + \toprule Name & In & Out & Exceptions \\\hline + \midrule + \texttt{\_\_init\_\_} & \texttt{output\_dir: Path} & None & None \\\hline + \texttt{refactor} & \texttt{file\_path: Path, pylint\_smell: dict, initial\_emissions: float} & None & None \\ + \hline + \bottomrule +\end{tabularx} + +\subsection{Semantics} + +\subsubsection{State Variables} +\begin{itemize} + \item \texttt{temp\_dir: Path}: Directory path for storing refactored files. +\end{itemize} + +\subsubsection{Environment Variables} +None + +\subsubsection{Assumptions} +\begin{itemize} + \item \texttt{output\_dir} exists or can be created, and write permissions are available. +\end{itemize} + +\subsubsection{Access Routine Semantics} + +\paragraph{\texttt{\_\_init\_\_(self, output\_dir: Path)}} +\begin{itemize} + \item \textbf{transition}: Initializes the \texttt{temp\_dir} variable within \texttt{output\_dir}. + \item \textbf{output}: None. + \item \textbf{exception:} None. +\end{itemize} + +\paragraph{\texttt{refactor(self, file\_path: Path, pylint\_smell: dict, initial\_emissions: float)}} +\begin{itemize} + \item \textbf{transition}: Abstract method. No transition defined. + \item \textbf{output}: None. + \item \textbf{exception:} None. +\end{itemize} + +\subsubsection{Local Functions} +None. + +\newpage + +\section{MIS of Smell Data Type} \label{mis:smell} +\texttt{Smell} + +\subsection{Module} +Contains data related to a code smell. + +\subsection{Uses} +None + +\subsection{Syntax} +\noindent +\textbf{Exported Constants}: None + +\noindent +\textbf{Exported Access Programs}: None + +\subsection{Semantics} + +\subsubsection{State Variables} +\begin{itemize} + \item \texttt{absolutePath: str}: Absolute path to the source file containing the smell. + \item \texttt{column: int}: Starting column in the source file where the smell is detected. + \item \texttt{confidence: str}: Confidence level for the smell detection. + \item \texttt{endColumn: int | None}: Ending column for the smell location, if applicable. + \item \texttt{endLine: int | None}: Ending line number for the smell location, if applicable. + \item \texttt{occurences: dict}: Contains positional data related to where the smell is located in a code file. + \item \texttt{message: str}: Descriptive message explaining the smell. + \item \texttt{messageId: str}: Unique identifier for the specific message or warning. + \item \texttt{module: str}: Module or component name containing the smell. + \item \texttt{obj: str}: Specific object associated with the smell. + \item \texttt{path: str}: Relative path to the source file from the project root. + \item \texttt{symbol: str}: Symbol or code construct involved in the smell. + \item \texttt{type: str}: Type or category of the smell. +\end{itemize} + +\subsubsection{Environment Variables} +None + +\subsubsection{Assumptions} +\begin{itemize} + \item All values provided to the fields of \texttt{Smell} conform to the expected data types and constraints. +\end{itemize} + +\subsubsection{Access Routine Semantics} + +\paragraph{\texttt{Smell()}} +\begin{itemize} + \item \textbf{transition}: Creates a dictionary-like structure with the defined attributes representing a code smell. + \item \textbf{output}: Returns a \texttt{Smell} instance. +\end{itemize} + +\subsubsection{Local Functions} +None. + + +\newpage + +\section{MIS of Use List Accumulation Refactorer} \label{mis:ListAccum} + +\texttt{UseListAccumulationRefactorer} + +\subsection{Module} + +The \texttt{UseListAccumulationRefactorer} module identifies and refactors +string concatenations in loops in Python code to improve the performance and energy efficiency of the software. It specifically handles these concatenations by, instead, adding the string for each iteration to a list that is then converted to a string using Python's \texttt{join()} function, ensuring proper refactoring while maintaining the original functionality. + +\subsection{Uses} +\begin{itemize} + \item Uses \texttt{Smell} interface for data access + \item Inherits from \texttt{BaseRefactorer} + \item Inherits from Python's \texttt{ast} module's \texttt{NodeTransformer} +\end{itemize} + +\subsection{Syntax} +\noindent +\textbf{Exported Constants}: None + +\noindent +\textbf{Exported Access Programs}: + +\begin{tabularx}{\linewidth}{| + l| + >{\raggedright\arraybackslash}X| + l| + l|} + \toprule Name & In & Out & Exceptions \\ + \midrule + \texttt{\_\_init\_\_} & \texttt{output\_dir: Path} & None & None \\ + \hline + \texttt{refactor} & \texttt{file\_path: Path, pylint\_smell: Smell, initial\_emissions: Real} & None & \texttt{TypeError}, \texttt{IOError} \\ + \hline + \texttt{visit} & \texttt{node: nodes.NodeNG} & None & None \\ + \hline + \texttt{find\_last\_assignment} & \texttt{scope: nodes.NodeNG} & None & \texttt{TypeError} \\ + \hline + \texttt{find\_scope} & None & None & \texttt{TypeError} \\ + \hline + \texttt{add\_node\_to\_body} & \texttt{code\_file: str} & \texttt{str} & \texttt{TypeError} \\ + \bottomrule +\end{tabularx} + +\subsection{Semantics} + +\subsubsection{State Variables} +\begin{itemize} + \item \texttt{target\_line: int}: Line number where refactoring is applied. + \item \texttt{target\_node: ASTnode}: Node representing the concatenation variable. + \item \texttt{assign\_var: str}: Name of the variable the \texttt{target\_node} represents. + \item \texttt{last\_assign\_node: ASTnode}: Last initialization/assignment of the \texttt{assign\_var} prior to the start of the loop. + \item \texttt{concat\_node: ASTnode}: Node where concatenation occurs. + \item \texttt{scope\_node: ASTnode}: Scope where refactoring is inserted. + \item \texttt{outer\_loop: ASTnode}: Outermost loop before the start of the concatenation. +\end{itemize} + +\subsubsection{Environment Variables} +None + +\subsubsection{Assumptions} +\begin{itemize} + \item The input file contains valid Python syntax. + \item \texttt{pylint\_smell} provides a valid line number for the detected code smell. +\end{itemize} + +\subsubsection{Access Routine Semantics} + +\paragraph{\texttt{\_\_init\_\_(self, output\_dir: Path)}} +\begin{itemize} + \item \textbf{transition}: Initializes the refactorer with \texttt{output\_dir} and sets default state variables. + \item \textbf{output}: None. + \item \textbf{exception}: None +\end{itemize} + +\paragraph{\texttt{refactor(self, file\_path: Path, pylint\_smell: Smell, initial\_emissions: float)}} +\begin{itemize} + \item \textbf{transition}: Parses \texttt{file\_path}, identifies string concatenations in loops, modifies code for list accumulation, and writes refactored code to a file. + \item \textbf{output}: None. + \item \textbf{exception}: Raises \texttt{IOError} if input file cannot be read. Raises \texttt{TypeError} if source file cannot be parsed into an AST. +\end{itemize} + +\paragraph{\texttt{find\_last\_assignment(self, scope: nodes.NodeNG)}} +\begin{itemize} + \item \textbf{transition}: Identifies the last assignment of \texttt{assign\_var} within the given \texttt{scope}. + \item \textbf{output}: None. + \item \textbf{exception}: Raises \texttt{TypeError} if given scope is null. +\end{itemize} + +\paragraph{\texttt{find\_scope(self)}} +\begin{itemize} + \item \textbf{transition}: Finds the scope for refactoring based on AST node ancestry. + \item \textbf{output}: None. + \item \textbf{exception}: Raises \texttt{TypeError} if \texttt{concat\_node} is not set. +\end{itemize} + +\paragraph{\texttt{add\_node\_to\_body(self, code\_file: str)}} +\begin{itemize} + \item \textbf{transition}: Inserts list accumulation and join statements into \texttt{code\_file}. + \item \textbf{output}: Returns the modified source code as a string. + \item \textbf{exception}: Raises \texttt{TypeError} if \texttt{target\_node} or \texttt{outer\_loop} is not set. +\end{itemize} + +\subsubsection{Local Functions} +Functions for internal AST parsing, node manipulation, and validation are defined within the class but are not exported. + +\newpage + +\section{MIS of Make Method Static Refactorer} \label{mis:MakeStatic} + +\texttt{MakeStaticRefactorer} + +\subsection{Module} + +The \texttt{MakeStaticRefactorer} module identifies and refactors +class methods that don't make use of their instance attributes to improve the readability, performance and energy efficiency of the software. It specifically handles these methods by turning them into static functions and ensuring any calls to this method use the proper calling syntax. This ensures proper refactoring while maintaining the original functionality. + +\subsection{Uses} +\begin{itemize} + \item Uses \texttt{Smell} interface for data access + \item Inherits from \texttt{BaseRefactorer} + \item Inherits from Python's \texttt{ast} module's \texttt{NodeTransformer} +\end{itemize} + +\subsection{Syntax} +\noindent +\textbf{Exported Constants}: None + +\noindent +\textbf{Exported Access Programs}: + +\begin{tabularx}{\linewidth}{|l|>{\raggedright\arraybackslash}X|l|l|} + \toprule Name & In & Out & Exceptions \\ + \midrule + \texttt{\_\_init\_\_} & \texttt{output\_dir: Path} & None & None \\ + \hline + \texttt{refactor} & \texttt{file\_path: Path, pylint\_smell: Smell, initial\_emissions: $\mathbb{R}$} & None & \texttt{TypeError}, \texttt{IOError} \\ + \hline + \texttt{visit\_FunctionDef} & \texttt{node: FunctionDef} & \texttt{FunctionDef} & None \\ + \hline + \texttt{visit\_ClassDef} & \texttt{node: ClassDef} & \texttt{ClassDef} & None \\ + \hline + \texttt{visit\_Call} & \texttt{node: Call} & \texttt{Call} & None \\ + \bottomrule +\end{tabularx} + +\subsection{Semantics} + +\subsubsection{State Variables} +\begin{itemize} + \item \texttt{target\_line: int}: Line number where refactoring is applied. + \item \texttt{mim\_method\_class: str}: Class name containing the method to refactor. + \item \texttt{mim\_method: str}: Method name to refactor. +\end{itemize} + +\subsubsection{Environment Variables} +None + +\subsubsection{Assumptions} +\begin{itemize} + \item The input file contains valid Python syntax. + \item \texttt{pylint\_smell} provides a valid line number for the detected code smell. +\end{itemize} + +\subsubsection{Access Routine Semantics} + +\paragraph{\texttt{\_\_init\_\_(self, output\_dir: Path)}} +\begin{itemize} + \item \textbf{transition}: Initializes the refactorer with \texttt{output\_dir} and sets default state variables. + \item \textbf{output}: None. + \item \textbf{exception}: None. +\end{itemize} + +\paragraph{\texttt{refactor(self, file\_path: Path, pylint\_smell: Smell, initial\_emissions: float)}} +\begin{itemize} + \item \textbf{transition}: Parses \texttt{file\_path}, identifies the target function, modifies it to be static, and validates refactoring. + \item \textbf{output}: None. + \item \textbf{exception}: Raises \texttt{IOError} if input file cannot be read. Raises \texttt{TypeError} if source file cannot be parsed into an AST. +\end{itemize} + +\paragraph{\texttt{visit\_FunctionDef(self, node: ast.FunctionDef)}} +\begin{itemize} + \item \textbf{transition}: Adds the \texttt{staticmethod} decorator to the target method and removes the \texttt{self} parameter if present. + \item \textbf{output}: Returns the modified \texttt{FunctionDef} node. + \item \textbf{exception}: None +\end{itemize} + +\paragraph{\texttt{visit\_ClassDef(self, node: ast.ClassDef)}} +\begin{itemize} + \item \textbf{transition}: Identifies the class containing the target method. + \item \textbf{output}: Returns the modified \texttt{ClassDef} node. + \item \textbf{exception}: None. +\end{itemize} + +\paragraph{\texttt{visit\_Call(self, node: ast.Call)}} +\begin{itemize} + \item \textbf{transition}: Updates method call references to use the class name instead of \texttt{self}. + \item \textbf{output}: Returns the modified \texttt{Call} node. + \item \textbf{exception}: None. +\end{itemize} + +\subsubsection{Local Functions} +Functions for internal AST parsing, node transformation, and validation are defined within the class but are not exported. + +\newpage \section{MIS of LongElementChainRefactorer} @@ -378,23 +706,23 @@ \subsection{Syntax} \subsection{Semantics} -\subsubsection*{State Variables} +\subsubsection{State Variables} \begin{itemize} \item \texttt{file\_path: Path}: The path to the Python file being analyzed. \item \texttt{source\_code: ast.Module}: The parsed abstract syntax tree of the source file. \item \texttt{smells\_data: list[dict]}: A list of detected code smells, represented as dictionaries. \end{itemize} -\subsubsection*{Environment Variables} +\subsubsection{Environment Variables} None -\subsubsection*{Assumptions} +\subsubsection{Assumptions} \begin{itemize} \item The input file is valid Python code and can be parsed into an AST. \item Configuration settings, such as extra Pylint options and custom smell definitions, are valid. \end{itemize} -\subsubsection*{Access Routine Semantics} +\subsubsection{Access Routine Semantics} \paragraph{\texttt{\_\_init\_\_(self, file\_path: Path, source\_code: ast.Module)}} \begin{itemize} @@ -459,13 +787,81 @@ \subsubsection*{Access Routine Semantics} \item \textbf{exception:} None. \end{itemize} -\subsubsection*{Local Functions} +\subsubsection{Local Functions} \begin{itemize} \item \texttt{parse\_line(file\_path: Path, line: int)}: Parses a specific line of code into an AST node. \item \texttt{get\_lambda\_code(lambda\_node: ast.Lambda)}: Returns the string representation of a lambda expression. \end{itemize} +\newpage + +\section{MIS of Testing Functionality} + +\texttt{TestRunner} + +\subsection{Module} + +Responsible for validating that any refactorings made to the source code do not modify it's original functionality. + +\subsection{Uses} +\begin{itemize} + \item Uses Python's subprocess library +\end{itemize} + +\subsection{Syntax} +\noindent +\textbf{Exported Constants}: None + +\noindent +\textbf{Exported Access Programs}: + +\begin{tabularx}{\linewidth}{|l|>{\raggedright\arraybackslash}X|l|l|} +\hline +Name & In & Out & Exceptions \\ +\hline +\texttt{\_\_init\_\_} & \texttt{run\_command: str, project\_path: Path} & None & None \\ +\hline +\texttt{retained\_functionality} & None & \texttt{bool} & \texttt{CalledProcessError} \\ +\hline +\end{tabularx} + +\subsection{Semantics} + +\subsubsection{State Variables} +\begin{itemize} + \item \texttt{project\_path: Path}: Path to the source code directory. + \item \texttt{run\_command: str}: Command used to run the tests. +\end{itemize} + +\subsubsection{Environment Variables} +None + +\subsubsection{Assumptions} +\begin{itemize} + \item The provided \texttt{run\_command} is a valid shell command. + \item \texttt{project\_path} is a valid path working source code directory. +\end{itemize} + +\subsubsection{Access Routine Semantics} + +\paragraph{\texttt{\_\_init\_\_(self, run\_command: str, project\_path: Path)}} +\begin{itemize} + \item \textbf{transition}: Initializes the test runner with the given \texttt{run\_command} and \texttt{project\_path}. + \item \textbf{output}: None. + \item \textbf{exception}: None. +\end{itemize} + +\paragraph{\texttt{retained\_functionality(self)}} +\begin{itemize} + \item \textbf{transition}: Runs the specified test command in the given project path. Logs success or failure, including standard output and error streams. + \item \textbf{output}: Returns \texttt{True} if the tests passed; otherwise, returns \texttt{False}. + \item \textbf{exception}: Raises a \texttt{CalledProcessError} if an eror occurs while running the tests in a subprocess. +\end{itemize} + +\subsubsection{Local Functions} +None. + \newpage \section{MIS of Use A Generator Refactorer} \label{mis:UseGen} @@ -507,22 +903,22 @@ \subsection{Syntax} \subsection{Semantics} -\subsubsection*{State Variables} +\subsubsection{State Variables} \begin{itemize} \item \texttt{temp\_dir: Path}: Directory path for storing refactored files. \item \texttt{output\_dir: Path}: Directory path for saving final refactored code. \end{itemize} -\subsubsection*{Environment Variables} +\subsubsection{Environment Variables} None -\subsubsection*{Assumptions} +\subsubsection{Assumptions} \begin{itemize} \item The input file contains valid Python syntax. \item \texttt{pylint\_smell} provides a valid line number for the detected code smell. \end{itemize} -\subsubsection*{Access Routine Semantics} +\subsubsection{Access Routine Semantics} \paragraph{\texttt{\_\_init\_\_(self, output\_dir: Path)}} \begin{itemize} @@ -545,7 +941,7 @@ \subsubsection*{Access Routine Semantics} \item \textbf{exception}: None. \end{itemize} -\subsubsection*{Local Functions} +\subsubsection{Local Functions} Functions for internal AST parsing, node manipulation, and validation are defined within the class but are not exported. \newpage @@ -582,22 +978,22 @@ \subsection{Syntax} \subsection{Semantics} -\subsubsection*{State Variables} +\subsubsection{State Variables} \begin{itemize} \item \texttt{cached\_var\_name: str}: Name of the temporary variable used for caching. \item \texttt{target\_line: int}: Line number where refactoring is applied. \end{itemize} -\subsubsection*{Environment Variables} +\subsubsection{Environment Variables} None -\subsubsection*{Assumptions} +\subsubsection{Assumptions} \begin{itemize} \item The input file contains valid Python syntax. \item \texttt{pylint\_smell} provides valid occurrences of repeated calls with line numbers and call strings. \end{itemize} -\subsubsection*{Access Routine Semantics} +\subsubsection{Access Routine Semantics} \paragraph{\texttt{\_\_init\_\_(self, output\_dir: Path)}} \begin{itemize} @@ -613,7 +1009,7 @@ \subsubsection*{Access Routine Semantics} \item \textbf{exception}: Raises \texttt{IOError} if input file cannot be read. Raises \texttt{TypeError} if source file cannot be parsed into an AST. \end{itemize} -\subsubsection*{Local Functions} +\subsubsection{Local Functions} \begin{itemize} \item \texttt{\_get\_indentation(lines, line\_number)}: Determines the indentation of a specific line. \item \texttt{\_replace\_call\_in\_line(line, call\_string, cached\_var\_name)}: Replaces repeated calls with the cached variable. diff --git a/docs/Images/use_hierarchy_modules.png b/docs/Images/use_hierarchy_modules.png new file mode 100644 index 00000000..af6c57ff Binary files /dev/null and b/docs/Images/use_hierarchy_modules.png differ