Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 7, 2024
1 parent f2bea7b commit 77dc5e0
Show file tree
Hide file tree
Showing 9 changed files with 1,062 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -3,7 +3,7 @@ repos:
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: tests/capture_tools_output/cpp-linter/cpp-linter/test_git_lib.patch
exclude: ^tests/.*\.(?:patch|diff)$
- id: end-of-file-fixer
- id: check-docstring-first
- id: check-added-large-files
Expand Down
3 changes: 3 additions & 0 deletions tests/comments/test_comments.py
Expand Up @@ -91,6 +91,9 @@ def test_post_feedback(
text=(cache_path / f"pr_comments_pg{i}.json").read_text(
encoding="utf-8"
),
# to trigger a logged error, we'll modify the response when
# fetching page 2 of old comments and thread-comments is true
status_code=404 if i == 2 and thread_comments == "true" else 200
)

# load mock responses for push event
Expand Down
3 changes: 3 additions & 0 deletions tests/reviews/.clang-format
@@ -0,0 +1,3 @@
---
Language: Cpp
BasedOnStyle: WebKit
185 changes: 185 additions & 0 deletions tests/reviews/.clang-tidy
@@ -0,0 +1,185 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-*,bugprone-*,clang-analyzer-*,mpi-*,misc-*,readability-*'
WarningsAsErrors: ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: 'file'
CheckOptions:
- key: bugprone-argument-comment.CommentBoolLiterals
value: '0'
- key: bugprone-argument-comment.CommentCharacterLiterals
value: '0'
- key: bugprone-argument-comment.CommentFloatLiterals
value: '0'
- key: bugprone-argument-comment.CommentIntegerLiterals
value: '0'
- key: bugprone-argument-comment.CommentNullPtrs
value: '0'
- key: bugprone-argument-comment.CommentStringLiterals
value: '0'
- key: bugprone-argument-comment.CommentUserDefinedLiterals
value: '0'
- key: bugprone-argument-comment.IgnoreSingleArgument
value: '0'
- key: bugprone-argument-comment.StrictMode
value: '0'
- key: bugprone-assert-side-effect.AssertMacros
value: assert
- key: bugprone-assert-side-effect.CheckFunctionCalls
value: '0'
- key: bugprone-dangling-handle.HandleClasses
value: 'std::basic_string_view;std::experimental::basic_string_view'
- key: bugprone-dynamic-static-initializers.HeaderFileExtensions
value: ',h,hh,hpp,hxx'
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
value: ''
- key: bugprone-exception-escape.IgnoredExceptions
value: ''
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
value: '0'
- key: bugprone-not-null-terminated-result.WantToUseSafeFunctions
value: '1'
- key: bugprone-signed-char-misuse.CharTypdefsToIgnore
value: ''
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
value: '1'
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
value: '1'
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
value: '0'
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
value: '1'
- key: bugprone-string-constructor.LargeLengthThreshold
value: '8388608'
- key: bugprone-string-constructor.WarnOnLargeLength
value: '1'
- key: bugprone-suspicious-enum-usage.StrictMode
value: '0'
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
value: '5'
- key: bugprone-suspicious-missing-comma.RatioThreshold
value: '0.200000'
- key: bugprone-suspicious-missing-comma.SizeThreshold
value: '5'
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
value: ''
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
value: '1'
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
value: '0'
- key: bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit
value: '16'
- key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField
value: '1'
- key: bugprone-unused-return-value.CheckedFunctions
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty'
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: misc-definitions-in-headers.HeaderFileExtensions
value: ',h,hh,hpp,hxx'
- key: misc-definitions-in-headers.UseHeaderFileExtension
value: '1'
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
value: '1'
- key: misc-unused-parameters.StrictMode
value: '0'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: performance-faster-string-find.StringLikeClasses
value: 'std::basic_string'
- key: performance-for-range-copy.AllowedTypes
value: ''
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: '0'
- key: performance-inefficient-string-concatenation.StrictMode
value: '0'
- key: performance-inefficient-vector-operation.EnableProto
value: '0'
- key: performance-inefficient-vector-operation.VectorLikeClasses
value: '::std::vector'
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: '1'
- key: performance-move-constructor-init.IncludeStyle
value: llvm
- key: performance-no-automatic-move.AllowedTypes
value: ''
- key: performance-type-promotion-in-math-fn.IncludeStyle
value: llvm
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: ''
- key: performance-unnecessary-value-param.AllowedTypes
value: ''
- key: performance-unnecessary-value-param.IncludeStyle
value: llvm
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: readability-else-after-return.WarnOnUnfixable
value: '1'
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: readability-function-size.LineThreshold
value: '4294967295'
- key: readability-function-size.NestingThreshold
value: '4294967295'
- key: readability-function-size.ParameterThreshold
value: '4294967295'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-function-size.VariableThreshold
value: '4294967295'
- key: readability-identifier-naming.IgnoreFailedSplit
value: '0'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: '0'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: '0'
- key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
value: '1'
- key: readability-inconsistent-declaration-parameter-name.Strict
value: '0'
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: '0'
- key: readability-redundant-smartptr-get.IgnoreMacros
value: '1'
- key: readability-redundant-string-init.StringNames
value: '::std::basic_string'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: '0'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: '0'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
value: '3'
- key: readability-uppercase-literal-suffix.IgnoreMacros
value: '1'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
108 changes: 108 additions & 0 deletions tests/reviews/pr_27.diff
@@ -0,0 +1,108 @@
diff --git a/.github/workflows/cpp-lint-package.yml b/.github/workflows/cpp-lint-package.yml
index 0418957..3b8c454 100644
--- a/.github/workflows/cpp-lint-package.yml
+++ b/.github/workflows/cpp-lint-package.yml
@@ -7,6 +7,7 @@ on:
description: 'which branch to test'
default: 'main'
required: true
+ pull_request:

jobs:
cpp-linter:
@@ -14,9 +15,9 @@ jobs:

strategy:
matrix:
- clang-version: ['7', '8', '9','10', '11', '12', '13', '14', '15', '16', '17']
+ clang-version: ['10', '11', '12', '13', '14', '15', '16', '17']
repo: ['cpp-linter/cpp-linter']
- branch: ['${{ inputs.branch }}']
+ branch: ['pr-review-suggestions']
fail-fast: false

steps:
@@ -62,10 +63,12 @@ jobs:
-i=build
-p=build
-V=${{ runner.temp }}/llvm
- -f=false
--extra-arg="-std=c++14 -Wall"
- --thread-comments=${{ matrix.clang-version == '12' }}
- -a=${{ matrix.clang-version == '12' }}
+ --file-annotations=false
+ --lines-changed-only=true
+ --thread-comments=${{ matrix.clang-version == '16' }}
+ --tidy-review=${{ matrix.clang-version == '16' }}
+ --format-review=${{ matrix.clang-version == '16' }}

- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
diff --git a/src/demo.cpp b/src/demo.cpp
index 0c1db60..1bf553e 100644
--- a/src/demo.cpp
+++ b/src/demo.cpp
@@ -1,17 +1,18 @@
/** This is a very ugly test code (doomed to fail linting) */
#include "demo.hpp"
-#include <cstdio>
-#include <cstddef>
+#include <stdio.h>

-// using size_t from cstddef
-size_t dummyFunc(size_t i) { return i; }

-int main()
-{
- for (;;)
- break;
+
+
+int main(){
+
+ for (;;) break;
+

printf("Hello world!\n");

- return 0;
-}
+
+
+
+ return 0;}
diff --git a/src/demo.hpp b/src/demo.hpp
index 2695731..f93d012 100644
--- a/src/demo.hpp
+++ b/src/demo.hpp
@@ -5,12 +5,10 @@
class Dummy {
char* useless;
int numb;
+ Dummy() :numb(0), useless("\0"){}

public:
- void *not_usefull(char *str){
- useless = str;
- return 0;
- }
+ void *not_useful(char *str){useless = str;}
};


@@ -28,14 +26,11 @@ class Dummy {



-
-
-
-


struct LongDiff
{
+
long diff;

};

0 comments on commit 77dc5e0

Please sign in to comment.