feat: reorder include statements to ensure corresponding headers are placed first

This commit is contained in:
whaffman 2025-09-30 11:17:43 +02:00
parent 4ff7a03597
commit a3e9699eb9
22 changed files with 39 additions and 19 deletions

View File

@ -3,9 +3,8 @@
./check_iwyu.sh ./check_iwyu.sh
./fix_iwyu_auto.sh ./fix_iwyu_auto.sh
# Reorder includes to put corresponding header first
./reorder_includes.sh
find webserv -name "*.hpp" -o -name "*.cpp" | xargs sed -i -E 's/#include "(.*)"/#include <\1>/g' find webserv -name "*.hpp" -o -name "*.cpp" | xargs sed -i -E 's/#include "(.*)"/#include <\1>/g'
find webserv -name "*.cpp" -o -name "*.hpp" | xargs clang-format -i find webserv -name "*.cpp" -o -name "*.hpp" | xargs clang-format -i
find webserv -name "*.hpp" -exec sh -c 'if ! grep -q "#pragma once" "$1"; then echo "Missing #pragma once in $1"; fi' _ {} \; find webserv -name "*.hpp" -exec sh -c 'if ! grep -q "#pragma once" "$1"; then echo "Missing #pragma once in $1"; fi' _ {} \;
# Reorder includes to put corresponding header first
./reorder_includes.sh

View File

@ -1,4 +1,5 @@
#include <webserv/client/Client.hpp> #include <webserv/client/Client.hpp>
#include <webserv/config/ConfigManager.hpp> // for ConfigManager #include <webserv/config/ConfigManager.hpp> // for ConfigManager
#include <webserv/config/ServerConfig.hpp> // for ServerConfig #include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/handler/ErrorHandler.hpp> // for ErrorHandler #include <webserv/handler/ErrorHandler.hpp> // for ErrorHandler

View File

@ -1,4 +1,5 @@
#include <webserv/config/AConfig.hpp> // for AConfig #include <webserv/config/AConfig.hpp> // for AConfig
#include <webserv/config/directive/ADirective.hpp> // for ADirective #include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory #include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory
#include <webserv/config/utils.hpp> // for trim #include <webserv/config/utils.hpp> // for trim

View File

@ -1,4 +1,5 @@
#include <webserv/config/ConfigManager.hpp> #include <webserv/config/ConfigManager.hpp>
#include <webserv/config/GlobalConfig.hpp> // for GlobalConfig #include <webserv/config/GlobalConfig.hpp> // for GlobalConfig
#include <webserv/config/utils.hpp> // for removeComments #include <webserv/config/utils.hpp> // for removeComments
#include <webserv/log/Log.hpp> // for Log #include <webserv/log/Log.hpp> // for Log

View File

@ -1,4 +1,5 @@
#include <webserv/config/GlobalConfig.hpp> #include <webserv/config/GlobalConfig.hpp>
#include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace #include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace
#include <webserv/log/Log.hpp> // for Log #include <webserv/log/Log.hpp> // for Log

View File

@ -1,5 +1,6 @@
#include <webserv/config/AConfig.hpp> // for AConfig
#include <webserv/config/LocationConfig.hpp> #include <webserv/config/LocationConfig.hpp>
#include <webserv/config/AConfig.hpp> // for AConfig
#include <webserv/log/Log.hpp> // for Log, LOCATION #include <webserv/log/Log.hpp> // for Log, LOCATION
LocationConfig::LocationConfig(const std::string &block, const AConfig *parent) : AConfig(parent) LocationConfig::LocationConfig(const std::string &block, const AConfig *parent) : AConfig(parent)

View File

@ -1,6 +1,7 @@
#include <webserv/config/ServerConfig.hpp>
#include <webserv/config/AConfig.hpp> // for AConfig #include <webserv/config/AConfig.hpp> // for AConfig
#include <webserv/config/LocationConfig.hpp> // for LocationConfig #include <webserv/config/LocationConfig.hpp> // for LocationConfig
#include <webserv/config/ServerConfig.hpp>
#include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace, trim #include <webserv/config/utils.hpp> // for findCorrespondingClosingBrace, trim
#include <webserv/log/Log.hpp> // for Log, LOCATION #include <webserv/log/Log.hpp> // for Log, LOCATION

View File

@ -1,4 +1,5 @@
#include <webserv/config/directive/ADirective.hpp> #include <webserv/config/directive/ADirective.hpp>
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValue, operator<< #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValue, operator<<
DirectiveValue ADirective::getValue() const DirectiveValue ADirective::getValue() const

View File

@ -1,5 +1,6 @@
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/BoolDirective.hpp> // for IntDirective #include <webserv/config/directive/BoolDirective.hpp> // for IntDirective
#include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <webserv/config/utils.hpp> // for trim #include <webserv/config/utils.hpp> // for trim

View File

@ -1,5 +1,6 @@
#include <webserv/config/directive/BoolDirective.hpp> // for BoolDirective
#include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory #include <webserv/config/directive/DirectiveFactory.hpp> // for DirectiveFactory
#include <webserv/config/directive/BoolDirective.hpp> // for BoolDirective
#include <webserv/config/directive/IntDirective.hpp> // for IntDirective #include <webserv/config/directive/IntDirective.hpp> // for IntDirective
#include <webserv/config/directive/IntStringDirective.hpp> // for IntStringDirective #include <webserv/config/directive/IntStringDirective.hpp> // for IntStringDirective
#include <webserv/config/directive/SizeDirective.hpp> // for SizeDirective #include <webserv/config/directive/SizeDirective.hpp> // for SizeDirective

View File

@ -1,6 +1,7 @@
#include <webserv/config/directive/IntDirective.hpp> // for IntDirective
#include <webserv/config/directive/ADirective.hpp> // for ADirective #include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <webserv/config/directive/IntDirective.hpp> // for IntDirective
IntDirective::IntDirective(const std::string &name, const std::string &value) IntDirective::IntDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters) : ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)

View File

@ -1,6 +1,7 @@
#include <webserv/config/directive/IntStringDirective.hpp> // for IntDirective
#include <webserv/config/directive/ADirective.hpp> // for ADirective #include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <webserv/config/directive/IntStringDirective.hpp> // for IntDirective
#include <webserv/config/utils.hpp> // for trim #include <webserv/config/utils.hpp> // for trim
#include <sstream> // for basic_istringstream, basic_istream::operator>>, istringstream #include <sstream> // for basic_istringstream, basic_istream::operator>>, istringstream

View File

@ -1,6 +1,7 @@
#include <webserv/config/directive/SizeDirective.hpp> // for SizeDirective
#include <webserv/config/directive/ADirective.hpp> // for ADirective #include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <webserv/config/directive/SizeDirective.hpp> // for SizeDirective
#include <webserv/config/utils.hpp> // for trim #include <webserv/config/utils.hpp> // for trim
#include <algorithm> // for __transform_fn, transform #include <algorithm> // for __transform_fn, transform

View File

@ -1,6 +1,7 @@
#include <webserv/config/directive/StringDirective.hpp> // for IntDirective
#include <webserv/config/directive/ADirective.hpp> // for ADirective #include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <webserv/config/directive/StringDirective.hpp> // for IntDirective
StringDirective::StringDirective(const std::string &name, const std::string &value) StringDirective::StringDirective(const std::string &name, const std::string &value)
: ADirective(name) // NOLINT(bugprone-easily-swappable-parameters) : ADirective(name) // NOLINT(bugprone-easily-swappable-parameters)

View File

@ -1,6 +1,7 @@
#include <webserv/config/directive/VectorDirective.hpp> // for IntDirective
#include <webserv/config/directive/ADirective.hpp> // for ADirective #include <webserv/config/directive/ADirective.hpp> // for ADirective
#include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType #include <webserv/config/directive/DirectiveValue.hpp> // for DirectiveValueType
#include <webserv/config/directive/VectorDirective.hpp> // for IntDirective
#include <sstream> // for basic_stringstream, stringstream #include <sstream> // for basic_stringstream, stringstream

View File

@ -1,6 +1,7 @@
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <webserv/config/utils.hpp> // for trim #include <webserv/config/utils.hpp> // for trim
#include <webserv/http/HttpConstants.hpp> // for CRLF #include <webserv/http/HttpConstants.hpp> // for CRLF
#include <webserv/http/HttpHeaders.hpp> // for HttpHeaders
#include <webserv/log/Log.hpp> #include <webserv/log/Log.hpp>
#include <algorithm> // for __transform_fn, transform #include <algorithm> // for __transform_fn, transform

View File

@ -1,7 +1,8 @@
#include <webserv/http/HttpRequest.hpp>
#include <webserv/client/Client.hpp> // for Client #include <webserv/client/Client.hpp> // for Client
#include <webserv/config/utils.hpp> // for stoul #include <webserv/config/utils.hpp> // for stoul
#include <webserv/http/HttpConstants.hpp> // for CRLF, DOUBLE_CRLF, BAD_REQUEST #include <webserv/http/HttpConstants.hpp> // for CRLF, DOUBLE_CRLF, BAD_REQUEST
#include <webserv/http/HttpRequest.hpp>
#include <webserv/log/Log.hpp> // for Log, LOCATION #include <webserv/log/Log.hpp> // for Log, LOCATION
#include <map> // for map #include <map> // for map

View File

@ -1,4 +1,5 @@
#include <webserv/log/FileChannel.hpp> #include <webserv/log/FileChannel.hpp>
#include <webserv/log/Log.hpp> // for Log #include <webserv/log/Log.hpp> // for Log
#include <chrono> // for system_clock #include <chrono> // for system_clock

View File

@ -1,6 +1,7 @@
#include <webserv/log/Log.hpp>
#include <webserv/log/Channel.hpp> // for Channel #include <webserv/log/Channel.hpp> // for Channel
#include <webserv/log/FileChannel.hpp> // for FileChannel #include <webserv/log/FileChannel.hpp> // for FileChannel
#include <webserv/log/Log.hpp>
#include <webserv/log/StdoutChannel.hpp> // for StdoutChannel #include <webserv/log/StdoutChannel.hpp> // for StdoutChannel
#include <chrono> // for duration_cast, operator-, steady_clock, duration, seconds #include <chrono> // for duration_cast, operator-, steady_clock, duration, seconds

View File

@ -1,6 +1,7 @@
#include <webserv/log/Log.hpp> // for Log
#include <webserv/log/StdoutChannel.hpp> #include <webserv/log/StdoutChannel.hpp>
#include <webserv/log/Log.hpp> // for Log
#include <iomanip> // for operator<<, setfill, setw #include <iomanip> // for operator<<, setfill, setw
#include <iostream> // for basic_ostream, operator<<, basic_ostream::operator<<, cerr, cout, flush, ostream #include <iostream> // for basic_ostream, operator<<, basic_ostream::operator<<, cerr, cout, flush, ostream

View File

@ -1,8 +1,9 @@
#include <webserv/server/Server.hpp>
#include <webserv/client/Client.hpp> // for Client #include <webserv/client/Client.hpp> // for Client
#include <webserv/config/ConfigManager.hpp> // for ConfigManager #include <webserv/config/ConfigManager.hpp> // for ConfigManager
#include <webserv/config/ServerConfig.hpp> // for ServerConfig #include <webserv/config/ServerConfig.hpp> // for ServerConfig
#include <webserv/log/Log.hpp> // for Log #include <webserv/log/Log.hpp> // for Log
#include <webserv/server/Server.hpp>
#include <webserv/socket/Socket.hpp> // for Socket #include <webserv/socket/Socket.hpp> // for Socket
#include <cerrno> // for errno #include <cerrno> // for errno

View File

@ -1,6 +1,7 @@
#include <webserv/log/Log.hpp>
#include <webserv/socket/Socket.hpp> #include <webserv/socket/Socket.hpp>
#include <webserv/log/Log.hpp>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>