Module: Mulang::Expectation
- Defined in:
- lib/mulang/expectation.rb
Defined Under Namespace
Modules: I18n
Classes: Custom, Standard, V0, V2
Constant Summary
collapse
- LOGIC_SMELLS =
%w(
HasRedundantReduction
UsesCut
UsesFail
UsesUnificationOperator
)
- FUNCTIONAL_SMELLS =
%w(
HasRedundantGuards
HasRedundantParameter
ShouldUseOtherwise
)
- OBJECT_ORIENTED_SMELLS =
%w(
DoesNilTest
DoesNullTest
HasTooManyMethods
OverridesEqualOrHashButNotBoth
ReturnsNil
ReturnsNull
DoesTypeTest
)
- IMPERATIVE_SMELLS =
%w(
HasAssignmentCondition
HasAssignmentReturn
HasEmptyRepeat
HasRedundantRepeat
)
- EXPRESSIVENESS_SMELLS =
%w(
HasMisspelledBindings
HasMisspelledIdentifiers
HasTooShortIdentifiers
HasWrongCaseBinding
HasWrongCaseIdentifiers
)
- GENERIC_SMELLS =
%w(
DiscardsExceptions
DoesConsolePrint
HasCodeDuplication
HasDeclarationTypos
HasEmptyIfBranches
HasEqualIfBranches
HasLongParameterList
HasRedundantBooleanComparison
HasRedundantLocalVariableReturn
HasRedundantIf
HasRedundantLambda
HasTooShortBindings
HasUnreachableCode
HasUsageTypos
IsLongCode
ShouldInvertIfCondition
ShouldUseStrictComparators
)
- JAVA_SCRIPT_SMELLS =
%w(
JavaScript#UsesVarInsteadOfLet
)
- SMELLS =
GENERIC_SMELLS +
EXPRESSIVENESS_SMELLS +
IMPERATIVE_SMELLS +
OBJECT_ORIENTED_SMELLS +
FUNCTIONAL_SMELLS +
LOGIC_SMELLS +
JAVA_SCRIPT_SMELLS
Class Method Summary
collapse
Class Method Details
.guess_type(expectation) ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/mulang/expectation.rb', line 72
def self.guess_type(expectation)
if expectation[:binding] == '<<custom>>'
Custom
elsif expectation[:inspection] =~ /^(Not\:)?Has.*/ && !has_smell?(expectation[:inspection])
V0
else
V2
end
end
|
.has_smell?(smell) ⇒ Boolean
82
83
84
|
# File 'lib/mulang/expectation.rb', line 82
def self.has_smell?(smell)
SMELLS.include? smell.split(':').first
end
|
.parse(expectation) ⇒ Object
86
87
88
|
# File 'lib/mulang/expectation.rb', line 86
def self.parse(expectation)
guess_type(expectation).parse(expectation)
end
|
.valid?(expectation) ⇒ Boolean
90
91
92
|
# File 'lib/mulang/expectation.rb', line 90
def self.valid?(expectation)
guess_type(expectation).valid?(expectation)
end
|