New paste Repaste Download
#include <expected>
#include <cmath>
// for printf to not get warnings about std::print throwing...
#include <cstdio>
std::expected<int, int> squareRoot(int value)
{
    if (value < 0)
    {
        return std::unexpected{0};
    } else {
        return std::sqrt(value);
    }
}
void sillySquareRootNoReturn(int value)
{
    auto valueResult = squareRoot(value);
    if (not valueResult)
    {
        // NOLINTNEXTLINE(modernize-use-std-print)
        printf("Error: invalid value %d\n", value);
        return;
    }
    auto root = valueResult.value();
    // NOLINTNEXTLINE(modernize-use-std-print)
    printf("the square root of %d is %d\n", value, root);
}
int sillySquareRootWithReturn(int value)
{
    auto valueResult = squareRoot(value);
    if (not valueResult)
    {
        // NOLINTNEXTLINE(modernize-use-std-print)
        printf("Error: invalid value %d\n", value);
        return 0;
    }
    return valueResult.value();
}
int main() {
    int value = -9;
    sillySquareRootNoReturn(value);
    // NOLINTNEXTLINE(modernize-use-std-print)
    printf("the square root of %d is %d\n", value, sillySquareRootWithReturn(value));
    return 0;
}
Filename: stupidtidy.cpp. Size: 1kb. View raw, , hex, or download this file.
project(
  'stupidtidy',
  'cpp',
  meson_version : '>= 1.3.0',
  version : '0.1',
  default_options : ['warning_level=3', 'cpp_std=c++23'],
  license : 'MIT',
)
sources = ['stupidtidy.cpp']
exe = executable(
  'stupidtidy',
  [sources],
  dependencies : [],
  install : true,
)
test('basic', exe)
# instructions:
# meson setup build
# meson compile -C build
# ./build/stupidtidy
# run-clang-tidy -p build
Filename: meson.build. Size: 431b. View raw, , hex, or download this file.
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,bugprone*'
WarningsAsErrors: ''
HeaderFileExtensions:
  - ''
  - h
  - hh
  - hpp
  - hxx
ImplementationFileExtensions:
  - c
  - cc
  - cpp
  - cxx
HeaderFilterRegex: ''
FormatStyle:     none
CheckOptions:
  cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
SystemHeaders:   false
...
Filename: .clang-tidy. Size: 347b. View raw, , hex, or download this file.
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,bugprone*'
WarningsAsErrors: ''
HeaderFileExtensions:
  - ''
  - h
  - hh
  - hpp
  - hxx
ImplementationFileExtensions:
  - c
  - cc
  - cpp
  - cxx
HeaderFilterRegex: ''
FormatStyle:     none
CheckOptions:
  cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU'
SystemHeaders:   false
...
Filename: None. Size: 347b. View raw, , hex, or download this file.

This paste expires on 2026-05-20 05:09:00.991449+00:00. Pasted through web.