google / blockly-android

Blockly for Android
Apache License 2.0
672 stars 209 forks source link

Fix assertion Checkstyle warnings in core #699

Closed ChrisCanCompute closed 6 years ago

ChrisCanCompute commented 6 years ago

Assertions are unreliable in Dalvik and unimplemented in ART. Use BuildConfig.DEBUG conditional checks instead.


This change is Reviewable

ChrisCanCompute commented 6 years ago

I'll look into the failing tests.

AnmAtAnm commented 6 years ago

Thanks. I was lazy when writing these. It would be great if there was a function call for these, though I know that would incur the call overhead for something that should really never happen. Fix up the line lengths and I'll pull this in.


Review status: 0 of 3 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed.


blocklylib-core/src/main/java/com/google/blockly/android/ui/fieldview/BasicFieldAngleView.java, line 43 at r1 (raw file):

        public void onValueChanged(Field angleField, String oldValue, String newValue) {
            if (BuildConfig.DEBUG && !(angleField == mAngleField)) {
                throw new AssertionError(String.format("angleField (%s) must match mAngleField (%s)",

line length should be 100 chars


blocklylib-core/src/main/java/com/google/blockly/model/BlockTemplate.java, line 438 at r1 (raw file):

    BlockTemplate withFieldValue(String fieldName, String value) {
        if (BuildConfig.DEBUG && (TextUtils.isEmpty(fieldName) || TextUtils.isEmpty(value))) {
            throw new AssertionError(String.format("Neither fieldName (%s) nor value (%s) may be blank",

line length should be 100 chars


Comments from Reviewable

AnmAtAnm commented 6 years ago

The travis breakage is the usual #653 flakiness unrelated to this change.

AnmAtAnm commented 6 years ago
:lgtm:

Review status: 0 of 2 files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable