moosetechnology / ClassNameAnalyser

MIT License
5 stars 2 forks source link

Don't hardcode the array of non alphanumeric characters #10

Closed olekscode closed 5 years ago

olekscode commented 5 years ago

Rewrite this:

DMNameTokenizer >> checkSpecialChar: aCharacter

    | arrayOfNonAlphaNumerics |
    arrayOfNonAlphaNumerics := #('#' '''' '.' '"' '@' '-' '_' '$' '£' '°' '!' '?' '&' '²' '^' '[' ']' '('   ')' '%' '/' '`' '{' '}' ':' ';' '=' '*' '+').
    (arrayOfNonAlphaNumerics includes: (aCharacter))
        ifTrue: [ ^ true ]
        ifFalse: [ ^ false ]

To this:

DMNameTokenizer >> checkSpecialChar: aCharacter
    ^ aCharacter isAlphaNumeric not.
olekscode commented 5 years ago

Also, this is hilarious :)

booleanExpression
    ifTrue: [ ^ true ]
    ifFalse: [ ^ false ].

You can just write

^ booleanExpression
Ducasse commented 5 years ago

And also move up return :)

booleanExpression ifTrue: [ ^ xxx ] ifFalse: [ ^ yyy ].

^ booleanExpression ifTrue: [ ^ xxx ] ifFalse: [ ^ yyy ].

olekscode commented 5 years ago

You mean this :)

^ booleanExpression
ifTrue: [ xxx ]
ifFalse: [ yyy ].
NourJihene commented 5 years ago

Done, hope it is what you meant.

Le mer. 15 mai 2019 à 11:18, Oleksandr Zaytsev notifications@github.com a écrit :

You mean this :)

^ booleanExpressionifTrue: [ xxx ]ifFalse: [ yyy ].

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/NourDjihan/ClassNameAnalyser/issues/10?email_source=notifications&email_token=AIKTML4GB3PDZGJ3JOWZT6DPVPIMRA5CNFSM4HGAFEU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVOBV6Q#issuecomment-492575482, or mute the thread https://github.com/notifications/unsubscribe-auth/AIKTML6PXEUUMBXN3FMU6NDPVPIMRANCNFSM4HGAFEUQ .