Introduction
In dynamic Web applications, there often exist several types of client-side code smells that violate important principles in software development such as software modularity and separation of concerns, resulting in much maintenance effort. Detecting and fixing those code smells is crucial yet challenging since client-side code is embedded and generated from server-side code.
This paper introduces WebScent, a tool to detect such embedded code smells. It first detects the smells in the generated code. It then locates them in the server-side code using the mapping between client-side code fragments and their embedding locations in the server program, which is captured during the generation of those fragments. Our empirical evaluation on real-world Web applications shows that 34%-81% of the tested server files contain embedded code smells. Importantly, we found that the source files with more embedded code smells are likely to have more defects and more scattered changes, thus potentially require more maintenance effort.