Skip to content

Commit a57766e

Browse files
webwornclaude
andcommitted
fix: Simplify clang-format configuration and ensure consistent formatting
- Replace complex clang-format configuration with minimal settings - Apply consistent formatting across all source files - Ensure maximum compatibility with different clang-format versions - Resolve CI/CD code quality analysis failures 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 22db1be commit a57766e

17 files changed

+70
-225
lines changed

.clang-format

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,9 @@
1-
# Simple clang-format configuration for OpenFOAM MCP Server
2-
# Based on Google style for maximum compatibility
3-
41
---
52
Language: Cpp
63
BasedOnStyle: Google
7-
8-
# Basic settings
94
IndentWidth: 4
105
TabWidth: 4
116
UseTab: Never
127
ColumnLimit: 100
13-
14-
# Simpler brace style
158
BreakBeforeBraces: Attach
16-
17-
# Standard alignment
18-
AlignAfterOpenBracket: Align
19-
AlignConsecutiveAssignments: false
20-
AlignConsecutiveDeclarations: false
21-
AlignOperands: Align
22-
AlignTrailingComments: true
23-
24-
# Allow short constructs
25-
AllowShortBlocksOnASingleLine: Empty
26-
AllowShortCaseLabelsOnASingleLine: false
27-
AllowShortFunctionsOnASingleLine: Empty
28-
AllowShortIfStatementsOnASingleLine: Never
29-
AllowShortLoopsOnASingleLine: false
30-
31-
# Bin packing
32-
BinPackArguments: true
33-
BinPackParameters: true
34-
35-
# Pointer alignment
36-
PointerAlignment: Left
37-
38-
# Include sorting
39-
SortIncludes: CaseInsensitive
40-
41-
# Spacing
42-
SpaceAfterCStyleCast: false
43-
SpaceAfterLogicalNot: false
44-
SpaceBeforeAssignmentOperators: true
45-
SpaceBeforeParens: ControlStatements
46-
SpacesBeforeTrailingComments: 2
47-
SpacesInAngles: Never
48-
SpacesInParentheses: false
49-
SpacesInSquareBrackets: false
50-
51-
# C++ standard
529
Standard: c++20

src/main.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include <exception>
22
#include <iostream>
33

4+
#include "Time.H"
45
#include "argList.H"
56
#include "foamVersion.H"
67
#include "mcp/server.hpp"
7-
#include "Time.H"
88
#include "tools/external_flow_tool.hpp"
99
#include "tools/heat_transfer_tool.hpp"
1010
#include "tools/pipe_flow_tool.hpp"
@@ -52,8 +52,7 @@ int main(int argc, char* argv[]) {
5252
auto tools = server.getRegisteredTools();
5353
for (size_t i = 0; i < tools.size(); ++i) {
5454
std::cerr << tools[i];
55-
if (i < tools.size() - 1)
56-
std::cerr << ", ";
55+
if (i < tools.size() - 1) std::cerr << ", ";
5756
}
5857
std::cerr << std::endl;
5958

src/mcp/json_rpc.hpp

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,10 @@ struct JsonRpcMessage {
5050

5151
JsonRpcMessage() : type(MessageType::INVALID), jsonrpc("2.0") {}
5252

53-
bool isRequest() const {
54-
return type == MessageType::REQUEST;
55-
}
56-
bool isResponse() const {
57-
return type == MessageType::RESPONSE;
58-
}
59-
bool isNotification() const {
60-
return type == MessageType::NOTIFICATION;
61-
}
62-
bool isValid() const {
63-
return type != MessageType::INVALID;
64-
}
53+
bool isRequest() const { return type == MessageType::REQUEST; }
54+
bool isResponse() const { return type == MessageType::RESPONSE; }
55+
bool isNotification() const { return type == MessageType::NOTIFICATION; }
56+
bool isValid() const { return type != MessageType::INVALID; }
6557
};
6658

6759
/*---------------------------------------------------------------------------*\
@@ -73,25 +65,15 @@ struct JsonRpcError {
7365
std::string message;
7466
std::optional<json> data;
7567

76-
static JsonRpcError parseError() {
77-
return {-32700, "Parse error", std::nullopt};
78-
}
68+
static JsonRpcError parseError() { return {-32700, "Parse error", std::nullopt}; }
7969

80-
static JsonRpcError invalidRequest() {
81-
return {-32600, "Invalid Request", std::nullopt};
82-
}
70+
static JsonRpcError invalidRequest() { return {-32600, "Invalid Request", std::nullopt}; }
8371

84-
static JsonRpcError methodNotFound() {
85-
return {-32601, "Method not found", std::nullopt};
86-
}
72+
static JsonRpcError methodNotFound() { return {-32601, "Method not found", std::nullopt}; }
8773

88-
static JsonRpcError invalidParams() {
89-
return {-32602, "Invalid params", std::nullopt};
90-
}
74+
static JsonRpcError invalidParams() { return {-32602, "Invalid params", std::nullopt}; }
9175

92-
static JsonRpcError internalError() {
93-
return {-32603, "Internal error", std::nullopt};
94-
}
76+
static JsonRpcError internalError() { return {-32603, "Internal error", std::nullopt}; }
9577

9678
static JsonRpcError serverError(int code, const std::string& message) {
9779
return {code, message, std::nullopt};

src/mcp/server.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,9 @@ void from_json(const json& j, ServerInfo& info) {
3434
j.at("name").get_to(info.name);
3535
j.at("version").get_to(info.version);
3636

37-
if (j.contains("description"))
38-
j.at("description").get_to(info.description);
39-
if (j.contains("author"))
40-
j.at("author").get_to(info.author);
41-
if (j.contains("homepage"))
42-
j.at("homepage").get_to(info.homepage);
37+
if (j.contains("description")) j.at("description").get_to(info.description);
38+
if (j.contains("author")) j.at("author").get_to(info.author);
39+
if (j.contains("homepage")) j.at("homepage").get_to(info.homepage);
4340
}
4441

4542
void to_json(json& j, const Tool& tool) {
@@ -73,9 +70,7 @@ McpServer::McpServer()
7370
setupStandardHandlers();
7471
}
7572

76-
McpServer::~McpServer() {
77-
stop();
78-
}
73+
McpServer::~McpServer() { stop(); }
7974

8075
void McpServer::setupStandardHandlers() {
8176
jsonRpcHandler_->registerRequestHandler(
@@ -145,9 +140,7 @@ json McpServer::handleToolsCall(const json& params) {
145140
return json(result);
146141
}
147142

148-
json McpServer::handlePing(const json& params) {
149-
return json::object();
150-
}
143+
json McpServer::handlePing(const json& params) { return json::object(); }
151144

152145
json McpServer::capabilitiesToJson(const ServerCapabilities& caps) const {
153146
json j = json::object();
@@ -158,10 +151,8 @@ json McpServer::capabilitiesToJson(const ServerCapabilities& caps) const {
158151

159152
if (caps.resources.subscribe || caps.resources.listChanged) {
160153
json resources = json::object();
161-
if (caps.resources.subscribe)
162-
resources["subscribe"] = true;
163-
if (caps.resources.listChanged)
164-
resources["listChanged"] = true;
154+
if (caps.resources.subscribe) resources["subscribe"] = true;
155+
if (caps.resources.listChanged) resources["listChanged"] = true;
165156
j["resources"] = resources;
166157
}
167158

src/mcp/server.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,11 @@ class McpServer {
166166

167167
void processStdinMessage();
168168

169-
bool isInitialized() const {
170-
return initialized_.load();
171-
}
172-
bool isRunning() const {
173-
return running_.load();
174-
}
169+
bool isInitialized() const { return initialized_.load(); }
170+
bool isRunning() const { return running_.load(); }
175171

176-
const ServerInfo& getServerInfo() const {
177-
return serverInfo_;
178-
}
179-
void setServerInfo(const ServerInfo& info) {
180-
serverInfo_ = info;
181-
}
172+
const ServerInfo& getServerInfo() const { return serverInfo_; }
173+
void setServerInfo(const ServerInfo& info) { serverInfo_ = info; }
182174

183175
std::vector<std::string> getRegisteredTools() const;
184176
};

src/openfoam/case_manager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,8 @@ void CaseManager::parseLogOutput(const std::string& caseId, const std::string& l
884884
try {
885885
double execTime = std::stod(timeStr);
886886
it->second->results["executionTime"] = execTime;
887-
} catch (const std::exception&) {}
887+
} catch (const std::exception&) {
888+
}
888889
}
889890
}
890891
}

src/openfoam/case_manager.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,9 @@ struct CaseResult {
7070

7171
CaseResult() : status("unknown"), exitCode(-1), executionTime(0) {}
7272

73-
bool isSuccess() const {
74-
return status == "completed" && exitCode == 0;
75-
}
76-
bool isRunning() const {
77-
return status == "running";
78-
}
79-
bool isFailed() const {
80-
return status == "failed" || exitCode != 0;
81-
}
73+
bool isSuccess() const { return status == "completed" && exitCode == 0; }
74+
bool isRunning() const { return status == "running"; }
75+
bool isFailed() const { return status == "failed" || exitCode != 0; }
8276
};
8377

8478
/*---------------------------------------------------------------------------*\
@@ -126,9 +120,7 @@ class CaseManager {
126120
bool deleteCaseData(const std::string& caseId);
127121

128122
void setWorkingDirectory(const fs::path& workingDir);
129-
fs::path getWorkingDirectory() const {
130-
return workingDirectory_;
131-
}
123+
fs::path getWorkingDirectory() const { return workingDirectory_; }
132124

133125
bool validateCaseParameters(const CaseParameters& params) const;
134126

src/openfoam/external_flow.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,13 @@ void from_json(const json& j, ExternalFlowInput& input) {
4242
j.at("velocity").get_to(input.velocity);
4343
j.at("characteristicLength").get_to(input.characteristicLength);
4444

45-
if (j.contains("frontalArea"))
46-
j.at("frontalArea").get_to(input.frontalArea);
47-
if (j.contains("altitude"))
48-
j.at("altitude").get_to(input.altitude);
49-
if (j.contains("fluidType"))
50-
j.at("fluidType").get_to(input.fluidType);
51-
if (j.contains("objective"))
52-
j.at("objective").get_to(input.objective);
53-
if (j.contains("density"))
54-
j.at("density").get_to(input.density);
55-
if (j.contains("viscosity"))
56-
j.at("viscosity").get_to(input.viscosity);
57-
if (j.contains("temperature"))
58-
j.at("temperature").get_to(input.temperature);
45+
if (j.contains("frontalArea")) j.at("frontalArea").get_to(input.frontalArea);
46+
if (j.contains("altitude")) j.at("altitude").get_to(input.altitude);
47+
if (j.contains("fluidType")) j.at("fluidType").get_to(input.fluidType);
48+
if (j.contains("objective")) j.at("objective").get_to(input.objective);
49+
if (j.contains("density")) j.at("density").get_to(input.density);
50+
if (j.contains("viscosity")) j.at("viscosity").get_to(input.viscosity);
51+
if (j.contains("temperature")) j.at("temperature").get_to(input.temperature);
5952
}
6053

6154
void to_json(json& j, const ExternalFlowResults& results) {
@@ -91,8 +84,7 @@ void from_json(const json& j, ExternalFlowResults& results) {
9184
j.at("caseId").get_to(results.caseId);
9285
j.at("success").get_to(results.success);
9386

94-
if (j.contains("errorMessage"))
95-
j.at("errorMessage").get_to(results.errorMessage);
87+
if (j.contains("errorMessage")) j.at("errorMessage").get_to(results.errorMessage);
9688
}
9789

9890
/*---------------------------------------------------------------------------*\

src/openfoam/external_flow.hpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ struct ExternalFlowInput {
6464
temperature(288.15) // 15°C
6565
{}
6666

67-
double getReynoldsNumber() const {
68-
return velocity * characteristicLength / viscosity;
69-
}
67+
double getReynoldsNumber() const { return velocity * characteristicLength / viscosity; }
7068

7169
double getMachNumber() const {
7270
double speedOfSound = std::sqrt(1.4 * 287.0 * temperature); // air at temperature
@@ -77,17 +75,11 @@ struct ExternalFlowInput {
7775
return getReynoldsNumber() < 500000; // external flow transition much higher
7876
}
7977

80-
bool isTurbulent() const {
81-
return getReynoldsNumber() > 1000000;
82-
}
78+
bool isTurbulent() const { return getReynoldsNumber() > 1000000; }
8379

84-
bool isCompressible() const {
85-
return getMachNumber() > 0.3;
86-
}
80+
bool isCompressible() const { return getMachNumber() > 0.3; }
8781

88-
bool isHighSpeed() const {
89-
return getMachNumber() > 0.8;
90-
}
82+
bool isHighSpeed() const { return getMachNumber() > 0.8; }
9183
};
9284

9385
/*---------------------------------------------------------------------------*\

src/openfoam/heat_transfer.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ namespace MCP {
1919
HeatTransferAnalyzer Implementation
2020
\*---------------------------------------------------------------------------*/
2121

22-
HeatTransferAnalyzer::HeatTransferAnalyzer() {
23-
initializeMaterialDatabase();
24-
}
22+
HeatTransferAnalyzer::HeatTransferAnalyzer() { initializeMaterialDatabase(); }
2523

2624
HeatTransferResults HeatTransferAnalyzer::analyze(const HeatTransferInput& input) {
2725
HeatTransferResults results = {};
@@ -231,12 +229,9 @@ double HeatTransferAnalyzer::calculateReynoldsNumber(const HeatTransferInput& in
231229

232230
double HeatTransferAnalyzer::calculatePrandtlNumber(const HeatTransferInput& input) const {
233231
// Typical Prandtl numbers
234-
if (input.coolantType == "air")
235-
return 0.7;
236-
if (input.coolantType == "water")
237-
return 7.0;
238-
if (input.coolantType == "oil")
239-
return 100.0;
232+
if (input.coolantType == "air") return 0.7;
233+
if (input.coolantType == "water") return 7.0;
234+
if (input.coolantType == "oil") return 100.0;
240235
return 0.7; // Default
241236
}
242237

0 commit comments

Comments
 (0)