approvals / ApprovalTests.cpp

Native ApprovalTests for C++ on Linux, Mac and Windows
https://approvaltestscpp.readthedocs.io/en/latest/
Apache License 2.0
318 stars 51 forks source link

ApprovalTests.v.8.3.0.hpp(2385): warning C26444: Avoid unnamed objects with custom construction and destruction (es.84). #100

Open alastairUK opened 4 years ago

alastairUK commented 4 years ago

Looking at the results of Visual Studio code analysis on my project using the default Microsoft Native Recommended Rules with the latest ApprovalTests header I see this warning:

ApprovalTests.v.8.3.0.hpp(2385): warning C26444: Avoid unnamed objects with custom construction and destruction (es.84).

        explicit CIBuildOnlyReporter(std::shared_ptr<Reporter> reporter = std::make_shared<QuietReporter>())
            : m_reporter(reporter)
        {
        }

image

claremacrae commented 4 years ago

Thanks Alastair. I've read the help... https://docs.microsoft.com/en-us/visualstudio/code-quality/c26444?view=vs-2019

I'm not spotting what the unnamed - discarded - thing is... Can you see it?

claremacrae commented 4 years ago

I also can't load the screenshot image - I get:

Secure Connection Failed

An error occurred during a connection to user-images.githubusercontent.com. Cannot communicate securely with peer: no common encryption algorithm(s).

Error code: SSL_ERROR_NO_CYPHER_OVERLAP

I've been seeing this more and more in GitHub issues recently - did the image contain anything that wasn't in the text body of the report?

alastairUK commented 4 years ago

It was just a screenshot of where VS is putting the green squiggles. Basically it's under this:

explicit CIBuildOnlyReporter(std::shared_ptr<Reporter> reporter =

I am not sure I understand the issue it's flagging up but as it's the only code analysis warning I am seeing in my project i thought I would flag it up before disabling it with a pragma in my codebase.

claremacrae commented 4 years ago

I see the warning in VS2019 - and changing the code like this makes it go away, i.e. passing the argument as a const reference...

     public:
-        explicit CIBuildOnlyReporter(std::shared_ptr<Reporter> reporter =
+        explicit CIBuildOnlyReporter(const std::shared_ptr<Reporter>& reporter =
                                          std::make_shared<QuietReporter>())
             : m_reporter(reporter)
         {

I assume/speculate that it's something to do with the internals of std::shared_ptr...

isidore commented 3 years ago

We are placing this on hold until we see it on a windows machine.