Skip to content

fix: address cpplint warnings across LogMonitor sources#225

Merged
bobsira merged 13 commits into
mainfrom
version2.2.0-rc
Apr 29, 2026
Merged

fix: address cpplint warnings across LogMonitor sources#225
bobsira merged 13 commits into
mainfrom
version2.2.0-rc

Conversation

@bobsira
Copy link
Copy Markdown
Contributor

@bobsira bobsira commented Apr 27, 2026

Summary

Resolves cpplint violations flagged by the CI reviewdog check that were
not included in the v2.2.0-rc release commit.

  • Fix header guards in pch.h, version.h, and resource.h to use the
    full-path style required by cpplint (LOGMONITOR_SRC_LOGMONITOR_*_H_)
  • Add NOLINT suppressions for build/include_subdir and
    build/include_order where the precompiled-header ordering cannot be
    changed without breaking implicit include dependencies
  • Add missing explicit #include directives (<map>, <vector>, <queue>,
    <string>, <memory>, <cstdio>) to headers that use those types directly
  • Indent public:/private: access specifiers +1 space inside class bodies
  • Remove blank lines after public: labels
  • Mark the single-parameter JsonFileParser(const std::wstring&) constructor
    explicit
  • Normalize inconsistent method indentation in FileMonitorUtilities.h
  • Fix line-length and trailing-whitespace violations

Test plan

  • CI cpplint reviewdog check passes with no new warnings
  • Build succeeds in Visual Studio with no new warnings
  • Existing log streaming behaviour is unchanged

CharityKathure and others added 13 commits April 15, 2025 17:50
* boost json parser

Signed-off-by: Charity Kathure <ckathure@microsoft.com>

Co-authored-by: Charity Kathure <ckathure@microsoft.com>
Signed-off-by: Charity Kathure <ckathure@microsoft.com>

* review: fix memory safety, error handling, and build improvements

- Use unique_ptr for channels vector in handleEventLog to eliminate manual
  delete and prevent memory leak on early return paths
- SanitizeJson no longer replaces log content with placeholder on failure;
  leaves str unchanged and logs via logWriter instead
- getJsonStringCaseInsensitive adds required param (default false) so optional
  fields don't emit spurious errors; required fields (name, level, directory,
  providerName, providerGuid) now pass true
- Fix inconsistent nlohmann::json vs json alias in handleETWLog/handleProcessLog
- build.cmd: detect cmake from VS or vcpkg when not on PATH; use goto to avoid
  delayed expansion issues with nested if blocks
- docs: remove leading space from "Information" level in README example

---------

Signed-off-by: Charity Kathure <ckathure@microsoft.com>
Co-authored-by: Charity Kathure <ckathure@microsoft.com>
Co-authored-by: Bob Sira <Bob.Sira@microsoft.com>
The SDL pipeline was failing because nlohmann/json.hpp was not available
when MSBuild compiled the project. Added vcpkg setup and nlohmann-json
installation steps before the build step.
- Fix boolean attributes stored as wstring* instead of bool* in
  JsonProcessor, causing incorrect EventFormatMultiLine/StartAtOldestRecord
  values after parsing
- Fix eventFormatMultiLine default from false to true (documented default)
- Make channel level optional in EventLog source (defaults to Error)
- Fix processSources to skip invalid sources and continue (resilient mode)
- Add missing waitInSeconds parsing in handleFileLog
- Fix path injection in Main.cpp: validate config filename and anchor to
  exe directory using GetModuleFileNameW/PathCombineW
- Fix %s -> %hs format specifier for narrow string in EtwMonitor.cpp
- Rename Utility string conversion functions to PascalCase
- Fix CMake toolchain file setup to run before project() call
- Fix output directory to use generator expression for multi-config layout
- Add JsonProcessorTests covering case-insensitive keys, optional field
  defaults, waitInSeconds parsing, and invalid source resilience
The VS .sln build compiles sources by #including them into
LogMonitorTests.cpp. JsonProcessor.cpp was missing from that list,
causing an unresolved external symbol for ReadConfigFile(PWCHAR,...).

- Add #include of JsonProcessor.cpp to LogMonitorTests.cpp
- Add #include "JsonProcessor.h" in JsonProcessor.cpp so all function
  declarations (with correct defaults) are visible when the file is
  #included as a translation unit, fixing C3861/C2660 errors
Both x64 and x86 jobs now install nlohmann-json via vcpkg before
building. --no-binarycaching and VCPKG_BINARY_SOURCES=clear prevent
vcpkg from downloading PowerShell Core (causing 504 errors in CI).
- Enable C++17 in CMakeLists.txt (fixes STL4038 for <variant>)
- Remove unused hr, bytesWritten, hSubscription, eventsCount, szBuf
  local variables (C4189)
- Replace E_FAIL (HRESULT) returns from DWORD functions with
  ERROR_UNHANDLED_EXCEPTION (C4245)
- Mark unused Buffer and Event parameters as commented-out (C4100)
- Rename shadowed 'status' variable in EventMonitor to 'retryStatus' (C4456)
- Replace wchar_t-to-char narrowing in FileMonitorUtilities with
  Utility::WStringToString (C4244)
- Remove dead functions BufferCopy, BufferCopyAndSanitize, ClearBuffer
  from ProcessMonitor.cpp (C4505)
- Replace deprecated std::wstring_convert with Win32 APIs
  (WideCharToMultiByte / MultiByteToWideChar)
- Add missing #include directives and fix cpplint style issues in
  JsonProcessor.cpp/.h and Utility.cpp/.h
- Minor test cleanup and build script fixes (bootstrap call, vcpkg flags)
…nings

Move JsonProcessor.h before standard library headers in JsonProcessor.cpp
and add Utility.h before standard headers in Utility.cpp to satisfy
cpplint's required include ordering: own header, c system, c++ system, other.
…ibility

- Case-insensitive lookup for LogConfig, logFormat, and sources keys to
  match previous parser behavior (configs using logconfig/LOGCONFIG etc. now work)
- Case-insensitive source type matching (eventlog, FILE, etw all accepted)
- Normalize directory path via ParseDirectoryValue before storing (/ to \,
  strip trailing slashes) and validate via IsValidSourceFile
- Validate ETW providers array presence before processing; fix incorrect
  error message referencing 'channels' to reference 'providers'
- Accept providerName OR providerGuid for ETW providers (either is sufficient);
  skip and warn on entries where both are empty
- Downgrade missing logFormat from TraceError to TraceWarning (it is optional)
- Fix cleanupAttributes to delete void* through correct types to avoid UB
- Add findJsonKeyCaseInsensitive helper for object key lookup
- Fix header guards in pch.h, version.h, resource.h to use full-path style
- Add NOLINT suppressions for build/include_subdir and build/include_order
  where precompiled header ordering cannot be changed
- Add explicit includes (<map>, <vector>, <queue>, <string>, <memory>,
  <cstdio>) to headers that use those types directly
- Indent public:/private: access specifiers +1 space inside class bodies
- Remove blank lines after public: labels
- Mark single-parameter JsonFileParser constructor explicit
- Fix line-length and trailing-whitespace violations
- Normalize inconsistent method indentation in FileMonitorUtilities.h
The file lives inside FileMonitor/, so including "FileMonitor/FileMonitorUtilities.h"
causes MSVC to look for FileMonitor/FileMonitor/FileMonitorUtilities.h which does not
exist. Use the bare filename instead since the compiler already searches the source
file's own directory.
@bobsira bobsira merged commit b784aac into main Apr 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants