From d7bdb90bc9813e3d2cff9fc78b20b902a14a7c96 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Sun, 21 Oct 2012 10:33:11 +0200 Subject: [PATCH] Refactorizations in Report classes: - Base class destructor already calls Close() - removed redundant call - Avoid creation of temporary variable --- gui/csvreport.cpp | 9 +++------ gui/txtreport.cpp | 6 ++---- gui/xmlreportv1.cpp | 11 ++++------- gui/xmlreportv2.cpp | 11 ++++------- 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/gui/csvreport.cpp b/gui/csvreport.cpp index b894f17aa..18c242d62 100644 --- a/gui/csvreport.cpp +++ b/gui/csvreport.cpp @@ -30,17 +30,15 @@ CsvReport::CsvReport(const QString &filename, QObject * parent) : CsvReport::~CsvReport() { - Close(); } bool CsvReport::Create() { - bool success = false; if (Report::Create()) { mTxtWriter.setDevice(Report::GetFile()); - success = true; + return true; } - return success; + return false; } void CsvReport::WriteHeader() @@ -60,9 +58,8 @@ void CsvReport::WriteError(const ErrorItem &error) gui/test.cpp,23,error,Mismatching allocation and deallocation: k */ - QString line; const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]); - line += QString("%1,%2,").arg(file).arg(error.lines[error.lines.size() - 1]); + QString line = QString("%1,%2,").arg(file).arg(error.lines[error.lines.size() - 1]); line += QString("%1,%2").arg(GuiSeverity::toString(error.severity)).arg(error.summary); mTxtWriter << line << endl; diff --git a/gui/txtreport.cpp b/gui/txtreport.cpp index b6d34b5ff..89310f489 100644 --- a/gui/txtreport.cpp +++ b/gui/txtreport.cpp @@ -26,17 +26,15 @@ TxtReport::TxtReport(const QString &filename, QObject * parent) : TxtReport::~TxtReport() { - Close(); } bool TxtReport::Create() { - bool success = false; if (Report::Create()) { mTxtWriter.setDevice(Report::GetFile()); - success = true; + return true; } - return success; + return false; } void TxtReport::WriteHeader() diff --git a/gui/xmlreportv1.cpp b/gui/xmlreportv1.cpp index f73cceb57..91458e75d 100644 --- a/gui/xmlreportv1.cpp +++ b/gui/xmlreportv1.cpp @@ -46,27 +46,24 @@ XmlReportV1::~XmlReportV1() { delete mXmlReader; delete mXmlWriter; - Close(); } bool XmlReportV1::Create() { - bool success = false; if (Report::Create()) { mXmlWriter = new QXmlStreamWriter(Report::GetFile()); - success = true; + return true; } - return success; + return false; } bool XmlReportV1::Open() { - bool success = false; if (Report::Open()) { mXmlReader = new QXmlStreamReader(Report::GetFile()); - success = true; + return true; } - return success; + return false; } void XmlReportV1::WriteHeader() diff --git a/gui/xmlreportv2.cpp b/gui/xmlreportv2.cpp index cc38c2fc9..03a1ce321 100644 --- a/gui/xmlreportv2.cpp +++ b/gui/xmlreportv2.cpp @@ -52,27 +52,24 @@ XmlReportV2::~XmlReportV2() { delete mXmlReader; delete mXmlWriter; - Close(); } bool XmlReportV2::Create() { - bool success = false; if (Report::Create()) { mXmlWriter = new QXmlStreamWriter(Report::GetFile()); - success = true; + return true; } - return success; + return false; } bool XmlReportV2::Open() { - bool success = false; if (Report::Open()) { mXmlReader = new QXmlStreamReader(Report::GetFile()); - success = true; + return true; } - return success; + return false; } void XmlReportV2::WriteHeader()