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
HasRedundantLambda
HasRedundantParameter
ShouldUseOtherwise
)
- OBJECT_ORIENTED_SMELLS =
%w(
DoesNilTest
DoesNullTest
DoesTypeTest
HasTooManyMethods
OverridesEqualOrHashButNotBoth
ReturnsNil
ReturnsNull
UsesNamedSelfReference
)
- IMPERATIVE_SMELLS =
%w(
HasAssignmentCondition
HasAssignmentReturn
HasEmptyRepeat
HasRedundantRepeat
)
- EXPRESSIVENESS_SMELLS =
%w(
HasMisspelledBindings
HasMisspelledIdentifiers
HasTooShortBindings
HasTooShortIdentifiers
HasWrongCaseBinding
HasWrongCaseIdentifiers
)
- GENERIC_SMELLS =
%w(
DiscardsExceptions
DoesConsolePrint
HasCodeDuplication
HasDeclarationTypos
HasEmptyIfBranches
HasEqualIfBranches
HasLongParameterList
HasRedundantBooleanComparison
HasRedundantIf
HasRedundantLocalVariableReturn
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
73
74
75
76
77
78
79
80
81
|
# File 'lib/mulang/expectation.rb', line 73
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
83
84
85
|
# File 'lib/mulang/expectation.rb', line 83
def self.has_smell?(smell)
SMELLS.include? smell.split(':').first
end
|
.parse(expectation) ⇒ Object
87
88
89
|
# File 'lib/mulang/expectation.rb', line 87
def self.parse(expectation)
guess_type(expectation).parse(expectation)
end
|
.valid?(expectation) ⇒ Boolean
91
92
93
|
# File 'lib/mulang/expectation.rb', line 91
def self.valid?(expectation)
guess_type(expectation).valid?(expectation)
end
|