Skip to content

Conversation

@firewave
Copy link
Collaborator

@firewave firewave commented Apr 19, 2023

This starts to untangle the ErrorLogger implementation in CppcheckExecutor which handles three different cases and makes things unnecessarily complicated.

@firewave firewave changed the title CppcheckExecutor: use dedicated ErrorLogger printing error messages XML CppcheckExecutor: use dedicated ErrorLogger for printing error messages XML Apr 19, 2023
reportOut(msg.toXML());
}

void reportProgress(const std::string & /*filename*/, const char /*stage*/[], const std::size_t /*value*/) override
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danmar
I think we can remove reportProgress(). It is supposed to give progress messages at certain (albeit very few) stages which might be long-running. But actually getting such a message looks very unlikely and it doesn't really provide much value. It is not helpful to the user since there is nothing he can do about it. And if we get a report about a slow analysis this we simply profile it since we need the actual cause not just not some ballpark string.

I do see it being used as an cancellation callback but as that callback is hit very rarely that will probably not work as expected. That could be implemented via the Settings::terminated() check instead which is performed more often.

Sorry for having yet another off-topic discussion in a PR (we should really enable the discussions on the repo).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was that if analysis of a file takes minutes.. it will be helpful for the user to see that there is progress and that we haven't hanged. It was mostly for the GUI. Unfortunately it's not used in the GUI as far as I know it's not trivial to add it properly (technically it's easy but ui-wise not so easy). Technically we could add labels and progress bars for each thread in the mainwindow but it will waste precious space...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the command line a message is written every ~ 10 seconds. But the idea was to update the progress in the GUI more often maybe every seconds or so..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #5269.

@firewave
Copy link
Collaborator Author

This can be merged. I will add a new PR about the additional changes I suggested.


void reportErr(const ErrorMessage &msg) override
{
reportOut(msg.toXML());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the feeling we want to write errors to std::cerr

Copy link
Collaborator Author

@firewave firewave Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for printing the XML and moves the previous code which did the same:

void CppCheckExecutor::reportErr(const ErrorMessage &msg)
{
    if (mShowAllErrors) {
        reportOut(msg.toXML());
        return;
    }

Copy link
Owner

@danmar danmar Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this code only meant to be used if --errorlist is used? I assumed this errorlogger would be used to output warnings during normal analysis also.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

if (parser.getShowErrorMessages()) {
            mShowAllErrors = true;
            XMLErrorMessagesLogger xmlLogger;
            std::cout << ErrorMessage::getXMLHeader(settings.cppcheckCfgProductName);
            CppCheck::getErrorMessages(*this);
            CppCheck::getErrorMessages(xmlLogger);
            std::cout << ErrorMessage::getXMLFooter() << std::endl;
        }

It should probably be moved somewhere else. I have a refactoring of the CmdLineParser which moves some things around which might help with this.

This PR is just about cleaning up the ErrorLogger implementation in CppcheckExecutor a bit.

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