Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterChen13579 committed Feb 6, 2025
1 parent 4c25511 commit bc16c43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
18 changes: 7 additions & 11 deletions src/util/newconfig/ConfigDescription.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,27 +82,23 @@ struct ClioConfigDescription {
{
namespace fs = std::filesystem;

// Construct the full file path
fs::path const fullFilePath = path.string();

// Validate the directory exists
auto const dir = fs::path(fullFilePath).parent_path();
if (!dir.empty() && !fs::exists(dir))
auto const dir = path.parent_path();
if (!dir.empty() && !fs::exists(dir)) {
return std::unexpected<Error>{

Check warning on line 88 in src/util/newconfig/ConfigDescription.hpp

View check run for this annotation

Codecov / codecov/patch

src/util/newconfig/ConfigDescription.hpp#L88

Added line #L88 was not covered by tests
fmt::format("Error: Directory {} does not exist or provided path is invalid", dir.string())
fmt::format("Error: Directory '{}' does not exist or provided path is invalid", dir.string())
};

Check warning on line 90 in src/util/newconfig/ConfigDescription.hpp

View check run for this annotation

Codecov / codecov/patch

src/util/newconfig/ConfigDescription.hpp#L90

Added line #L90 was not covered by tests
}

std::ofstream file(fullFilePath);
std::ofstream file(path.string());
if (!file.is_open()) {
return std::unexpected{
fmt::format("Failed to create file '{}': {}", fullFilePath.string(), std::strerror(errno))
};
return std::unexpected{fmt::format("Failed to create file '{}': {}", path.string(), std::strerror(errno))};
}

writeConfigDescriptionToFile(file);
file.close();

std::cout << "Markdown file generated successfully: " << fullFilePath << "\n";
std::cout << "Markdown file generated successfully: " << path << "\n";
return {};
}

Expand Down
3 changes: 0 additions & 3 deletions tests/unit/app/CliArgsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ TEST_F(CliArgsTestsWithTmpFile, Parse_ConfigDescription)

// user provide config markdown file name as well
ASSERT_TRUE(std::filesystem::exists(tmpFile.path));
std::filesystem::remove(tmpFile.path);

EXPECT_EQ(
action.apply(
Expand Down Expand Up @@ -220,6 +219,4 @@ TEST_F(CliArgsTestsWithTmpFile, Parse_ConfigDescriptionFileContent)
// all keys that exist in clio config should be listed in config description file
for (auto const& key : gClioConfig)
EXPECT_TRUE(fileContent.find(key.first));

std::filesystem::remove(tmpFile.path);
}

0 comments on commit bc16c43

Please sign in to comment.