Skip to content

Commit

Permalink
Merge c4fb4e3 into 0cafd45
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryuichi Saito committed Jul 12, 2016
2 parents 0cafd45 + c4fb4e3 commit 6ffab37
Show file tree
Hide file tree
Showing 31 changed files with 118 additions and 51 deletions.
2 changes: 2 additions & 0 deletions oclint-driver/main_docgen.cpp
Expand Up @@ -125,6 +125,8 @@ void writeRuleToCategory(ofstream& out, oclint::RuleBase* rule)

out << "**Since: " << rule->since() << "**" << endl << endl;

out << "**Name: " << rule->name() << "**" << endl << endl;

out << rule->description() << endl << endl;

out << "This rule is defined by the following class: "
Expand Down
7 changes: 6 additions & 1 deletion oclint-rules/rules/basic/MisplacedNullCheckRule.cpp
Expand Up @@ -87,7 +87,7 @@ class MisplacedNullCheckRule : public MisplacedNullCheckBaseRule
virtual const std::string description() const override
{
return "The null check is misplaced. "
"In C and C++, sending a message to a null pointer could crash the app. "
"In C and C++, sending a message to a null pointer could crash the program. "
"When null is misplaced, either the check is useless or it's incorrect.";
}

Expand Down Expand Up @@ -160,6 +160,11 @@ class MisplacedNilCheckRule : public MisplacedNullCheckBaseRule
"But code readers may be confused about the misplaced nil check.";
}

virtual const std::string fileName() const override
{
return "MisplacedNullCheckRule.cpp";
}

virtual const std::string example() const override
{
return R"rst(
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/rules/basic/ReturnFromFinallyBlockRule.cpp
Expand Up @@ -50,7 +50,7 @@ class ReturnFromFinallyBlockRule : public AbstractASTVisitorRule<ReturnFromFinal

virtual const std::string description() const override
{
return "Returning from a finally block is not recommended.";
return "Returning from a ``finally`` block is not recommended.";
}

virtual const std::string example() const override
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/rules/cocoa/ObjCVerifyIsEqualHashRule.cpp
Expand Up @@ -15,7 +15,7 @@ class ObjCVerifyIsEqualHashRule : public AbstractASTVisitorRule<ObjCVerifyIsEqua
public:
virtual const string name() const override
{
return "must override hash with isEqual";
return "missing hash method";
}

virtual int priority() const override
Expand Down
11 changes: 8 additions & 3 deletions oclint-rules/rules/cocoa/ObjCVerifyMustCallSuperRule.cpp
Expand Up @@ -59,7 +59,12 @@ class ObjCVerifyMustCallSuperRule : public AbstractASTVisitorRule<ObjCVerifyMust
public:
virtual const string name() const override
{
return "must call super";
return "missing calling base method";
}

virtual const string attributeName() const override
{
return "base method";
}

virtual int priority() const override
Expand All @@ -86,7 +91,7 @@ class ObjCVerifyMustCallSuperRule : public AbstractASTVisitorRule<ObjCVerifyMust
virtual const std::string description() const override
{
return "When a method is declared with "
"``__attribute__((annotate(\"oclint:enforce[must call super]\")))`` annotation, "
"``__attribute__((annotate(\"oclint:enforce[base method]\")))`` annotation, "
"all of its implementations (including its own and its sub classes) "
"must call the method implementation in super class.";
}
Expand All @@ -102,7 +107,7 @@ class ObjCVerifyMustCallSuperRule : public AbstractASTVisitorRule<ObjCVerifyMust
.. code-block:: objective-c
@interface UIView (OCLintStaticChecks)
- (void)layoutSubviews __attribute__((annotate("oclint:enforce[must call super]")));
- (void)layoutSubviews __attribute__((annotate("oclint:enforce[base method]")));
@end
@interface CustomView : UIView
Expand Down
8 changes: 4 additions & 4 deletions oclint-rules/rules/cocoa/ObjCVerifyProhibitedCallRule.cpp
Expand Up @@ -40,12 +40,12 @@ class ObjCVerifyProhibitedCallRule : public AbstractASTVisitorRule<ObjCVerifyPro

virtual const string name() const override
{
return "verify prohibited call";
return "calling prohibited method";
}

virtual const string attributeName() const override
{
return "prohibited call";
return "prohibited method";
}

virtual int priority() const override
Expand All @@ -67,7 +67,7 @@ class ObjCVerifyProhibitedCallRule : public AbstractASTVisitorRule<ObjCVerifyPro
virtual const std::string description() const override
{
return "When a method is declared with "
"``__attribute__((annotate(\"oclint:enforce[prohibited call]\")))`` "
"``__attribute__((annotate(\"oclint:enforce[prohibited method]\")))`` "
"annotation, all of its usages will be prohibited.";
}

Expand All @@ -82,7 +82,7 @@ class ObjCVerifyProhibitedCallRule : public AbstractASTVisitorRule<ObjCVerifyPro
.. code-block:: objective-c
@interface A : NSObject
- (void)foo __attribute__((annotate("oclint:enforce[prohibited call]")));
- (void)foo __attribute__((annotate("oclint:enforce[prohibited method]")));
@end
@implementation A
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/rules/cocoa/ObjCVerifyProtectedMethodRule.cpp
Expand Up @@ -71,7 +71,7 @@ class ObjCVerifyProtectedMethodRule : public AbstractASTVisitorRule<ObjCVerifyPr

virtual const string name() const override
{
return "verify protected method";
return "calling protected method";
}

virtual const string attributeName() const override
Expand Down
11 changes: 8 additions & 3 deletions oclint-rules/rules/cocoa/ObjCVerifySubclassMustImplementRule.cpp
Expand Up @@ -16,7 +16,12 @@ class ObjCVerifySubclassMustImplementRule : public
public:
virtual const string name() const override
{
return "subclass must implement";
return "missing abstract method implementation";
}

virtual const string attributeName() const override
{
return "abstract method";
}

virtual int priority() const override
Expand All @@ -42,7 +47,7 @@ class ObjCVerifySubclassMustImplementRule : public

virtual const std::string description() const override
{
return "Due to the Objective-C language tries to postpone making decisions "
return "Due to the Objective-C language tries to postpone the decision makings "
"to the runtime as much as possible, an abstract method is okay to be declared "
"but without implementations. This rule tries to verify the subclass implement "
"the correct abstract method.";
Expand All @@ -60,7 +65,7 @@ class ObjCVerifySubclassMustImplementRule : public
@interface Parent
- (void)anAbstractMethod __attribute__((annotate("oclint:enforce[subclass must implement]")));
- (void)anAbstractMethod __attribute__((annotate("oclint:enforce[abstract method]")));
@end
Expand Down
Expand Up @@ -41,6 +41,11 @@ class BaseClassDestructorShouldBeVirtualOrProtectedRule :
return "base class destructor should be virtual or protected";
}

virtual const std::string identifier() const override
{
return "ProblematicBaseClassDestructor";
}

virtual int priority() const override
{
return 2;
Expand All @@ -64,7 +69,12 @@ class BaseClassDestructorShouldBeVirtualOrProtectedRule :

virtual const std::string description() const override
{
return "Make base class destructors public and virtual, or protected and nonvirtual";
return "Make base class destructor public and virtual, or protected and nonvirtual";
}

virtual const std::string fileName() const override
{
return "BaseClassDestructorShouldBeVirtualOrProtectedRule.cpp";
}

virtual const std::string example() const override
Expand Down
Expand Up @@ -11,7 +11,12 @@ class CoveredSwitchStatementsDontNeedDefaultRule :
public:
virtual const string name() const override
{
return "covered switch statements dont need default";
return "unnecessary default statement in covered switch statement";
}

virtual const string identifier() const override
{
return "UnnecessaryDefaultStatement";
}

virtual int priority() const override
Expand All @@ -38,6 +43,11 @@ class CoveredSwitchStatementsDontNeedDefaultRule :
"the SwitchStatementsShouldHaveDefault rule will report.";
}

virtual const std::string fileName() const override
{
return "CoveredSwitchStatementsDontNeedDefaultRule.cpp";
}

virtual const std::string example() const override
{
return R"rst(
Expand Down
Expand Up @@ -11,7 +11,12 @@ class DefaultLabelNotLastInSwitchStatementRule :
public:
virtual const string name() const override
{
return "default label not last in switch statement";
return "ill-placed default label in switch statement";
}

virtual const string identifier() const override
{
return "IllplacedDefaultLabel";
}

virtual int priority() const override
Expand All @@ -36,6 +41,11 @@ class DefaultLabelNotLastInSwitchStatementRule :
"in a switch statement.";
}

virtual const std::string fileName() const override
{
return "DefaultLabelNotLastInSwitchStatementRule.cpp";
}

virtual const std::string example() const override
{
return R"rst(
Expand Down
Expand Up @@ -72,6 +72,11 @@ class ObjCAssignIvarOutsideAccessorsRule:
return "ivar assignment outside accessors or init";
}

virtual const string identifier() const override
{
return "AssignIvarOutsideAccessors";
}

virtual int priority() const override
{
return 2;
Expand Down
7 changes: 6 additions & 1 deletion oclint-rules/rules/convention/PreferEarlyExitRule.cpp
Expand Up @@ -67,7 +67,12 @@ class PreferEarlyExitRule : public AbstractASTVisitorRule<PreferEarlyExitRule>
public:
virtual const string name() const override
{
return "use early exits and continue";
return "prefer early exits and continue";
}

virtual const string identifier() const override
{
return "PreferEarlyExit";
}

virtual int priority() const override
Expand Down
Expand Up @@ -11,7 +11,12 @@ class SwitchStatementsShouldHaveDefaultRule :
public:
virtual const string name() const override
{
return "switch statements should have default";
return "missing default in switch statements";
}

virtual const string identifier() const override
{
return "MissingDefaultStatement";
}

virtual int priority() const override
Expand All @@ -35,6 +40,11 @@ class SwitchStatementsShouldHaveDefaultRule :
return "Switch statements should have a default statement.";
}

virtual const std::string fileName() const override
{
return "SwitchStatementsShouldHaveDefaultRule.cpp";
}

virtual const std::string example() const override
{
return R"rst(
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/rules/migration/ObjCBoxedExpressionsRule.cpp
Expand Up @@ -80,7 +80,7 @@ class ObjCBoxedExpressionsRule : public AbstractASTVisitorRule<ObjCBoxedExpressi
public:
virtual const string name() const override
{
return "replace with boxed expression";
return "use boxed expression";
}

virtual int priority() const override
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/rules/migration/ObjCContainerLiteralsRule.cpp
Expand Up @@ -11,7 +11,7 @@ class ObjCContainerLiteralsRule : public AbstractASTVisitorRule<ObjCContainerLit
public:
virtual const string name() const override
{
return "replace with container literal";
return "use container literal";
}

virtual int priority() const override
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/rules/migration/ObjCNSNumberLiteralsRule.cpp
Expand Up @@ -74,7 +74,7 @@ class ObjCNSNumberLiteralsRule : public AbstractASTVisitorRule<ObjCNSNumberLiter
public:
virtual const string name() const override
{
return "replace with number literal";
return "use number literal";
}

virtual int priority() const override
Expand Down
Expand Up @@ -52,7 +52,7 @@ class ObjCObjectSubscriptingRule : public AbstractASTVisitorRule<ObjCObjectSubsc
public:
virtual const string name() const override
{
return "replace with object subscripting";
return "use object subscripting";
}

virtual int priority() const override
Expand Down
2 changes: 1 addition & 1 deletion oclint-rules/test/cocoa/ObjCVerifyIsEqualHashRuleTest.cpp
Expand Up @@ -71,7 +71,7 @@ TEST(ObjCVerifyIsEqualHashRuleTest, PropertyTest)
{
ObjCVerifyIsEqualHashRule rule;
EXPECT_EQ(1, rule.priority());
EXPECT_EQ("must override hash with isEqual", rule.name());
EXPECT_EQ("missing hash method", rule.name());
EXPECT_EQ("cocoa", rule.category());
}

Expand Down
6 changes: 3 additions & 3 deletions oclint-rules/test/cocoa/ObjCVerifyMustCallSuperRuleTest.cpp
Expand Up @@ -34,7 +34,7 @@ typedef unsigned char BOOL;
@interface SomeBaseClass : NSObject \n\
\n\
- (void)viewWillAppear:(BOOL)animated \n\
__attribute__((annotate(\"oclint:enforce[must call super]\"))); \n\
__attribute__((annotate(\"oclint:enforce[base method]\"))); \n\
\n\
@end \n\
\n\
Expand All @@ -51,7 +51,7 @@ static const string testSuppression = "\
@implementation ChildViewController \n\
\n\
- (void)viewWillAppear:(BOOL)animated \n\
__attribute__((annotate(\"oclint:suppress[must call super]\"))) { \n\
__attribute__((annotate(\"oclint:suppress[base method]\"))) { \n\
} \n\
\n\
@end \n\
Expand Down Expand Up @@ -94,7 +94,7 @@ TEST(ObjcVerifyMustCallSuperRuleTest, PropertyTest)
{
ObjCVerifyMustCallSuperRule rule;
EXPECT_EQ(1, rule.priority());
EXPECT_EQ("must call super", rule.name());
EXPECT_EQ("missing calling base method", rule.name());
EXPECT_EQ("cocoa", rule.category());
}

Expand Down

0 comments on commit 6ffab37

Please sign in to comment.