Code Smells are indicators of structural weaknesses
in software design and implementation that can reduce maintainability, scalability, and readability. To improve software quality
and support efficient maintenance, this study proposes a machine learning approach for the automated detection of Critical
Threshold Rule (CTR) violations, focusing on the Long Method
and Large Class smell types. In the feature selection stage,
six models, namely Decision Tree (DT), Random Forest (RF),
Logistic Regression (LR), Support Vector Machine (SVM), Multilayer Perceptron (MLP), and Stochastic Gradient Descent (SGD),
were combined with GridSearchCV, RandomizedSearchCV, Outof-Bag (OOB) validation, and SHAP values to raise both accuracy
and interpretability. After the best features were selected, thirteen
classifiers were trained and evaluated: LR, DT, RF, SVM,
Gaussian Naive Bayes (GNB), Multinomial Naive Bayes (MNB),
MLP, Linear Support Vector (Linear SV), K-Nearest Neighbors
(KNN), Gradient Boosting (GB), Extra Trees (ET), Bernoulli
Naive Bayes (BNB), and AdaBoost (AB). The models were trained
on datasets drawn from Software Development Versioning (SDV)
repositories that contain 1,000 log file entries. Across accuracy,
precision, recall, F1 score, and ROC AUC, ensemble models, and
RF in particular, gave the strongest results, reaching the highest
accuracy of 96.02% for Long Method and 92.63% for Large
Class. The findings were further confirmed by the Wilcoxon
signed-rank test. For practical use, the method was deployed
as a web application built with the React Native framework that
analyzes log data, flags smelly code segments, and reports their
severity to give developers actionable insight. The approach offers
a reliable and interpretable solution for Code Smell detection with
clear potential for integration into modern software development
