aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRenaud G <renaud@rolisteam.org>2016-01-08 20:54:21 +0100
committerRenaud G <renaud@rolisteam.org>2016-01-08 20:54:21 +0100
commitdb15e41502743d1124062eddb8d2bb3617e2593c (patch)
tree259d73b1be7b10efbfd125c118fc7d956a9b1aac
parent6a1a9f1c7f3c50d04d89cc54e93d08ed6f2c4cc2 (diff)
downloadOneRoll-db15e41502743d1124062eddb8d2bb3617e2593c.tar.gz
OneRoll-db15e41502743d1124062eddb8d2bb3617e2593c.zip
fix cppcheck errors
-rw-r--r--diceparser.cpp1
-rw-r--r--die.cpp6
-rw-r--r--die.h6
-rw-r--r--node/scalaroperatornode.cpp4
-rw-r--r--node/scalaroperatornode.h6
-rw-r--r--parsingtoolbox.cpp43
-rw-r--r--range.cpp4
-rw-r--r--range.h2
-rw-r--r--result/diceresult.cpp21
-rw-r--r--result/result.cpp2
-rw-r--r--result/result.h2
11 files changed, 32 insertions, 65 deletions
diff --git a/diceparser.cpp b/diceparser.cpp
index 86fbc09..796c3ce 100644
--- a/diceparser.cpp
+++ b/diceparser.cpp
@@ -114,7 +114,6 @@ DiceParser::~DiceParser()
m_start = NULL;
}
}
-
ExecutionNode* DiceParser::getLatestNode(ExecutionNode* node)
{
ExecutionNode* next = node;
diff --git a/die.cpp b/die.cpp
index 1b4b246..1eb94e0 100644
--- a/die.cpp
+++ b/die.cpp
@@ -110,7 +110,7 @@ void Die::roll(bool adding)
}
}
-quint64 Die::getFaces()
+quint64 Die::getFaces() const
{
return m_faces;
}
@@ -128,7 +128,7 @@ qint64 Die::getLastRolledValue()
else
return 0;
}
-bool Die::hasBeenDisplayed()
+bool Die::hasBeenDisplayed() const
{
return m_displayStatus;
}
@@ -141,7 +141,7 @@ void Die::setHighlighted(bool a)
m_highlighted = a;
}
-bool Die::isHighlighted()
+bool Die::isHighlighted() const
{
return m_highlighted;
}
diff --git a/die.h b/die.h
index 2c10894..ffd37a1 100644
--- a/die.h
+++ b/die.h
@@ -99,12 +99,12 @@ public:
* @brief getFaces
* @return
*/
- quint64 getFaces();
+ quint64 getFaces() const;
/**
* @brief hasBeenDisplayed
* @return
*/
- bool hasBeenDisplayed();
+ bool hasBeenDisplayed() const;
/**
* @brief displayed
*/
@@ -117,7 +117,7 @@ public:
* @brief isHighlighted
* @return
*/
- bool isHighlighted();
+ bool isHighlighted() const;
/**
* @brief setBase
diff --git a/node/scalaroperatornode.cpp b/node/scalaroperatornode.cpp
index f69cb01..67fda8d 100644
--- a/node/scalaroperatornode.cpp
+++ b/node/scalaroperatornode.cpp
@@ -109,7 +109,6 @@ bool ScalarOperatorNode::setOperatorChar(QChar c)
return false;
}
-
void ScalarOperatorNode::setInternalNode(ExecutionNode* node)
{
m_internalNode = node;
@@ -118,12 +117,10 @@ qint64 ScalarOperatorNode::add(qint64 a,qint64 b)
{
return a+b;
}
-
qint64 ScalarOperatorNode::substract(qint64 a,qint64 b)
{
return a-b;
}
-
qreal ScalarOperatorNode::divide(qint64 a,qint64 b)
{
if(b==0)
@@ -133,7 +130,6 @@ qreal ScalarOperatorNode::divide(qint64 a,qint64 b)
}
return (qreal)a/b;
}
-
qint64 ScalarOperatorNode::multiple(qint64 a,qint64 b)
{
return a*b;
diff --git a/node/scalaroperatornode.h b/node/scalaroperatornode.h
index ea0f7e1..ca6f3ac 100644
--- a/node/scalaroperatornode.h
+++ b/node/scalaroperatornode.h
@@ -53,10 +53,10 @@ public:
virtual QMap<ExecutionNode::ERROR_CODE,QString> getExecutionErrorMap();
private:
- qint64 add(qint64,qint64);
- qint64 substract(qint64,qint64);
+ static qint64 add(qint64,qint64);
+ static qint64 substract(qint64,qint64);
qreal divide(qint64,qint64);
- qint64 multiple(qint64,qint64);
+ static qint64 multiple(qint64,qint64);
private:
ScalarOperator m_operator;
diff --git a/parsingtoolbox.cpp b/parsingtoolbox.cpp
index d511e44..495ae6e 100644
--- a/parsingtoolbox.cpp
+++ b/parsingtoolbox.cpp
@@ -80,10 +80,6 @@ ParsingToolBox::~ParsingToolBox()
Validator* ParsingToolBox::readValidator(QString& str)
{
Validator* returnVal=NULL;
-
- bool isOk = true;
-
-
BooleanCondition::LogicOperator myLogicOp = BooleanCondition::Equal;
bool hasReadLogicOperator = readLogicOperator(str,myLogicOp);
qint64 value=0;
@@ -96,41 +92,18 @@ Validator* ParsingToolBox::readValidator(QString& str)
qint64 end=0;
if(readNumber(str,end))
{
- /* if(expectSquareBrasket)
- {
- if(str.startsWith("]"))
- {
- str=str.remove(0,1);
- isOk=true;
- }
- else
- {
- isOk=false;
- }
- }*/
- if(isOk)
- {
- str=str.remove(0,1);
- Range* range = new Range();
- range->setValue(value,end);
- returnVal = range;
- }
+ str=str.remove(0,1);
+ Range* range = new Range();
+ range->setValue(value,end);
+ returnVal = range;
}
}
else
{
- /* if((expectSquareBrasket)&&(str.startsWith("]")))
- {
- str=str.remove(0,1);
- isOk=true;
- }*/
- //if(isOk)
- {
- BooleanCondition* condition = new BooleanCondition();
- condition->setValue(value);
- condition->setOperator(myLogicOp);
- returnVal = condition;
- }
+ BooleanCondition* condition = new BooleanCondition();
+ condition->setValue(value);
+ condition->setOperator(myLogicOp);
+ returnVal = condition;
}
}
return returnVal;
diff --git a/range.cpp b/range.cpp
index 30c0812..337cdc1 100644
--- a/range.cpp
+++ b/range.cpp
@@ -79,9 +79,9 @@ void Range::setEnd(qint64 end)
m_hasEnd = true;
}
-bool Range::isFullyDefined()
+bool Range::isFullyDefined() const
{
- return (m_hasEnd & m_hasStart);
+ return (m_hasEnd && m_hasStart);
}
qint64 Range::getStart() const
{
diff --git a/range.h b/range.h
index f9849ce..75fc69a 100644
--- a/range.h
+++ b/range.h
@@ -40,7 +40,7 @@ public:
virtual QString toString();
virtual quint64 getValidRangeSize(quint64 faces) const;
- bool isFullyDefined();
+ bool isFullyDefined() const;
qint64 getStart() const;
qint64 getEnd() const;
diff --git a/result/diceresult.cpp b/result/diceresult.cpp
index ffa5d02..74aa4e1 100644
--- a/result/diceresult.cpp
+++ b/result/diceresult.cpp
@@ -46,19 +46,18 @@ DiceResult::~DiceResult()
}
QVariant DiceResult::getResult(RESULT_TYPE type)
{
-
switch (type)
{
- case SCALAR:
- return getScalarResult();
- break;
- case DICE_LIST:
- {
- return QVariant();
- break;
- }
- default:
- break;
+ case SCALAR:
+ {
+ return getScalarResult();
+ }
+ case DICE_LIST:
+ {
+ return QVariant();
+ }
+ default:
+ break;
}
return QVariant();
diff --git a/result/result.cpp b/result/result.cpp
index 7b6633c..163d539 100644
--- a/result/result.cpp
+++ b/result/result.cpp
@@ -37,7 +37,7 @@ void Result::setPrevious(Result* p)
m_previous = p;
}
-bool Result::isStringResult()
+bool Result::isStringResult() const
{
return false;
}
diff --git a/result/result.h b/result/result.h
index 3f16535..2a5b7f9 100644
--- a/result/result.h
+++ b/result/result.h
@@ -62,7 +62,7 @@ public:
* @brief isStringResult
* @return
*/
- bool isStringResult();
+ virtual bool isStringResult() const;
/**
* @brief getStringResult