Proceedings of the lnternatlonal Conference on Software Engineering and Knowledge Engineering, SEKE, Volume 2023-July, Pages 130-135, 2023 DOI: 10.18293/SEKE2023-125
abstract
Stack Overflow (SO) is one of the world's largest technical Q&A websites, in which many posts contain code snippets. However, these code snippets may not comply with coding style guidelines and result in the problem of low readability and maintainability. To provide a better understanding of this coding style compliance issue for SO users, we plan and conduct an empirical study on SO. Specifically, we collected over 400,000 code snippets from SO in three languages, namely Python, C/C++, and JavaScript. The posts are divided into two types (i.e., question and answer) and analyzed separately. We found that for the question- and answer-type posts, more than 90% and 60% of code snippets contain style violations. The most frequently found violation is syntax errors for Python and indentations for C/C++ and JavaScript. In addition, the results show that with more violations in code snippets, the Score" of Python and C/C++ posts, the
FavoriteCount" of C/C++ questions, and the ``CommentCount" of JavaScript questions tend to be lower. The findings of our research indicate that code snippets on SO do not have good coding style compliance. Users, especially programming beginners are supposed to be wary of the potential problems of reusing code snippets on SO.