Changeset 11942 in josm for trunk


Ignore:
Timestamp:
2017-04-17T04:58:33+02:00 (7 years ago)
Author:
Don-vip
Message:

sonar - fb-contrib:PME_POOR_MANS_ENUM - Style - Simple field is used like an enum

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r11746 r11942  
    707707        protected List<CheckerElement> data = new ArrayList<>();
    708708        private OsmPrimitiveType type;
    709         private int code;
     709        private TagCheckLevel level;
    710710        protected Severity severity;
    711         // CHECKSTYLE.OFF: SingleSpaceSeparator
    712         protected static final int TAG_CHECK_ERROR = 1250;
    713         protected static final int TAG_CHECK_WARN  = 1260;
    714         protected static final int TAG_CHECK_INFO  = 1270;
    715         // CHECKSTYLE.ON: SingleSpaceSeparator
     711
     712        private enum TagCheckLevel {
     713            TAG_CHECK_ERROR(1250),
     714            TAG_CHECK_WARN(1260),
     715            TAG_CHECK_INFO(1270);
     716
     717            final int code;
     718
     719            TagCheckLevel(int code) {
     720                this.code = code;
     721            }
     722        }
    716723
    717724        protected static class CheckerElement {
     
    809816            case "W":
    810817                severity = Severity.WARNING;
    811                 code = TAG_CHECK_WARN;
     818                level = TagCheckLevel.TAG_CHECK_WARN;
    812819                break;
    813820            case "E":
    814821                severity = Severity.ERROR;
    815                 code = TAG_CHECK_ERROR;
     822                level = TagCheckLevel.TAG_CHECK_ERROR;
    816823                break;
    817824            case "I":
    818825                severity = Severity.OTHER;
    819                 code = TAG_CHECK_INFO;
     826                level = TagCheckLevel.TAG_CHECK_INFO;
    820827                break;
    821828            default:
     
    847854        }
    848855
     856        /**
     857         * Returns the error description.
     858         * @return the error description
     859         */
    849860        public String getDescription() {
    850861            return description;
    851862        }
    852863
     864        /**
     865         * Returns the error severity.
     866         * @return the error severity
     867         */
    853868        public Severity getSeverity() {
    854869            return severity;
    855870        }
    856871
     872        /**
     873         * Returns the error code.
     874         * @return the error code
     875         */
    857876        public int getCode() {
    858877            if (type == null)
    859                 return code;
    860 
    861             return code + type.ordinal() + 1;
     878                return level.code;
     879
     880            return level.code + type.ordinal() + 1;
    862881        }
    863882    }
Note: See TracChangeset for help on using the changeset viewer.