Refactorizations in Report classes:
- Base class destructor already calls Close() - removed redundant call - Avoid creation of temporary variable
This commit is contained in:
parent
d1fad4b762
commit
d7bdb90bc9
|
@ -30,17 +30,15 @@ CsvReport::CsvReport(const QString &filename, QObject * parent) :
|
||||||
|
|
||||||
CsvReport::~CsvReport()
|
CsvReport::~CsvReport()
|
||||||
{
|
{
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsvReport::Create()
|
bool CsvReport::Create()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if (Report::Create()) {
|
if (Report::Create()) {
|
||||||
mTxtWriter.setDevice(Report::GetFile());
|
mTxtWriter.setDevice(Report::GetFile());
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsvReport::WriteHeader()
|
void CsvReport::WriteHeader()
|
||||||
|
@ -60,9 +58,8 @@ void CsvReport::WriteError(const ErrorItem &error)
|
||||||
gui/test.cpp,23,error,Mismatching allocation and deallocation: k
|
gui/test.cpp,23,error,Mismatching allocation and deallocation: k
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QString line;
|
|
||||||
const QString file = QDir::toNativeSeparators(error.files[error.files.size() - 1]);
|
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);
|
line += QString("%1,%2").arg(GuiSeverity::toString(error.severity)).arg(error.summary);
|
||||||
|
|
||||||
mTxtWriter << line << endl;
|
mTxtWriter << line << endl;
|
||||||
|
|
|
@ -26,17 +26,15 @@ TxtReport::TxtReport(const QString &filename, QObject * parent) :
|
||||||
|
|
||||||
TxtReport::~TxtReport()
|
TxtReport::~TxtReport()
|
||||||
{
|
{
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TxtReport::Create()
|
bool TxtReport::Create()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if (Report::Create()) {
|
if (Report::Create()) {
|
||||||
mTxtWriter.setDevice(Report::GetFile());
|
mTxtWriter.setDevice(Report::GetFile());
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TxtReport::WriteHeader()
|
void TxtReport::WriteHeader()
|
||||||
|
|
|
@ -46,27 +46,24 @@ XmlReportV1::~XmlReportV1()
|
||||||
{
|
{
|
||||||
delete mXmlReader;
|
delete mXmlReader;
|
||||||
delete mXmlWriter;
|
delete mXmlWriter;
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlReportV1::Create()
|
bool XmlReportV1::Create()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if (Report::Create()) {
|
if (Report::Create()) {
|
||||||
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
|
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlReportV1::Open()
|
bool XmlReportV1::Open()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if (Report::Open()) {
|
if (Report::Open()) {
|
||||||
mXmlReader = new QXmlStreamReader(Report::GetFile());
|
mXmlReader = new QXmlStreamReader(Report::GetFile());
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlReportV1::WriteHeader()
|
void XmlReportV1::WriteHeader()
|
||||||
|
|
|
@ -52,27 +52,24 @@ XmlReportV2::~XmlReportV2()
|
||||||
{
|
{
|
||||||
delete mXmlReader;
|
delete mXmlReader;
|
||||||
delete mXmlWriter;
|
delete mXmlWriter;
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlReportV2::Create()
|
bool XmlReportV2::Create()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if (Report::Create()) {
|
if (Report::Create()) {
|
||||||
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
|
mXmlWriter = new QXmlStreamWriter(Report::GetFile());
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XmlReportV2::Open()
|
bool XmlReportV2::Open()
|
||||||
{
|
{
|
||||||
bool success = false;
|
|
||||||
if (Report::Open()) {
|
if (Report::Open()) {
|
||||||
mXmlReader = new QXmlStreamReader(Report::GetFile());
|
mXmlReader = new QXmlStreamReader(Report::GetFile());
|
||||||
success = true;
|
return true;
|
||||||
}
|
}
|
||||||
return success;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmlReportV2::WriteHeader()
|
void XmlReportV2::WriteHeader()
|
||||||
|
|
Loading…
Reference in New Issue