http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/PngEncoder.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/PngEncoder.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/PngEncoder.as new file mode 100644 index 0000000..f11822b --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/PngEncoder.as @@ -0,0 +1,617 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.encoding +{ + import flash.geom.*; + import flash.display.*; + import flash.utils.*; + + public final class JPEGEncoder + { + + // Static table initialization + + internal var DU:Array = new Array(64); + + private var ZigZag:Array = [ + 0, 1, 5, 6,14,15,27,28, + 2, 4, 7,13,16,26,29,42, + 3, 8,12,17,25,30,41,43, + 9,11,18,24,31,40,44,53, + 10,19,23,32,39,45,52,54, + 20,22,33,38,46,51,55,60, + 21,34,37,47,50,56,59,61, + 35,36,48,49,57,58,62,63 + ]; + + private var YTable:Array = new Array(64); + private var UVTable:Array = new Array(64); + private var fdtbl_Y:Array = new Array(64); + private var fdtbl_UV:Array = new Array(64); + private var YDC_HT:Array; + private var UVDC_HT:Array; + private var YAC_HT:Array; + private var UVAC_HT:Array; + private var std_dc_luminance_nrcodes:Array = [0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0]; + private var std_dc_luminance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11]; + private var std_ac_luminance_nrcodes:Array = [0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d]; + private var std_ac_luminance_values:Array = [ + 0x01,0x02,0x03,0x00,0x04,0x11,0x05,0x12, + 0x21,0x31,0x41,0x06,0x13,0x51,0x61,0x07, + 0x22,0x71,0x14,0x32,0x81,0x91,0xa1,0x08, + 0x23,0x42,0xb1,0xc1,0x15,0x52,0xd1,0xf0, + 0x24,0x33,0x62,0x72,0x82,0x09,0x0a,0x16, + 0x17,0x18,0x19,0x1a,0x25,0x26,0x27,0x28, + 0x29,0x2a,0x34,0x35,0x36,0x37,0x38,0x39, + 0x3a,0x43,0x44,0x45,0x46,0x47,0x48,0x49, + 0x4a,0x53,0x54,0x55,0x56,0x57,0x58,0x59, + 0x5a,0x63,0x64,0x65,0x66,0x67,0x68,0x69, + 0x6a,0x73,0x74,0x75,0x76,0x77,0x78,0x79, + 0x7a,0x83,0x84,0x85,0x86,0x87,0x88,0x89, + 0x8a,0x92,0x93,0x94,0x95,0x96,0x97,0x98, + 0x99,0x9a,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7, + 0xa8,0xa9,0xaa,0xb2,0xb3,0xb4,0xb5,0xb6, + 0xb7,0xb8,0xb9,0xba,0xc2,0xc3,0xc4,0xc5, + 0xc6,0xc7,0xc8,0xc9,0xca,0xd2,0xd3,0xd4, + 0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xe1,0xe2, + 0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea, + 0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8, + 0xf9,0xfa + ]; + + private var std_dc_chrominance_nrcodes:Array = [0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0]; + private var std_dc_chrominance_values:Array = [0,1,2,3,4,5,6,7,8,9,10,11]; + private var std_ac_chrominance_nrcodes:Array = [0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77]; + private var std_ac_chrominance_values:Array = [ + 0x00,0x01,0x02,0x03,0x11,0x04,0x05,0x21, + 0x31,0x06,0x12,0x41,0x51,0x07,0x61,0x71, + 0x13,0x22,0x32,0x81,0x08,0x14,0x42,0x91, + 0xa1,0xb1,0xc1,0x09,0x23,0x33,0x52,0xf0, + 0x15,0x62,0x72,0xd1,0x0a,0x16,0x24,0x34, + 0xe1,0x25,0xf1,0x17,0x18,0x19,0x1a,0x26, + 0x27,0x28,0x29,0x2a,0x35,0x36,0x37,0x38, + 0x39,0x3a,0x43,0x44,0x45,0x46,0x47,0x48, + 0x49,0x4a,0x53,0x54,0x55,0x56,0x57,0x58, + 0x59,0x5a,0x63,0x64,0x65,0x66,0x67,0x68, + 0x69,0x6a,0x73,0x74,0x75,0x76,0x77,0x78, + 0x79,0x7a,0x82,0x83,0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x92,0x93,0x94,0x95,0x96, + 0x97,0x98,0x99,0x9a,0xa2,0xa3,0xa4,0xa5, + 0xa6,0xa7,0xa8,0xa9,0xaa,0xb2,0xb3,0xb4, + 0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xc2,0xc3, + 0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xd2, + 0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda, + 0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9, + 0xea,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8, + 0xf9,0xfa + ]; + private var bitcode:Array = new Array(65535); + private var category:Array = new Array(65535); + private var byteout:ByteArray; + private var bytenew:int = 0; + private var bytepos:int = 7; + private var YDU:Array = new Array(64); + private var UDU:Array = new Array(64); + private var VDU:Array = new Array(64); + + public function JPEGEncoder(quality:Number = 50) + { + if (quality <= 0) { + quality = 1; + } + if (quality > 100) { + quality = 100; + } + var sff:int = 0; + if (quality < 50) { + sff = int(5000 / quality); + } else { + sff = int(200 - quality*2); + } + // Create tables + initHuffmanTbl(); + initCategoryNumber(); + initQuantTables(sff); + } + + public function encode(image:BitmapData):ByteArray + { + // Initialize bit writer + byteout = new ByteArray(); + bytenew=0; + bytepos=7; + + // Add JPEG headers + writeWord(0xFFD8); // SOI + writeAPP0(); + writeDQT(); + writeSOF0(image.width,image.height); + writeDHT(); + writeSOS(); + + // Encode 8x8 macroblocks + var DCY:Number=0; + var DCU:Number=0; + var DCV:Number=0; + bytenew=0; + bytepos=7; + for (var ypos:int=0; ypos<image.height; ypos+=8) { + for (var xpos:int=0; xpos<image.width; xpos+=8) { + RGB2YUV(image, xpos, ypos); + DCY = processDU(YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); + DCU = processDU(UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); + return DCV = processDU(VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); + } + } + + // Do the bit alignment of the EOI marker + if ( bytepos >= 0 ) { + var fillbits:BitString = new BitString(); + fillbits.len = bytepos+1; + fillbits.val = (1<<(bytepos+1))-1; + writeBits(fillbits); + } + + writeWord(0xFFD9); //EOI + return byteout; + } + + private function initQuantTables(sf:int):void + { + var YQT:Array = [ + 16, 11, 10, 16, 24, 40, 51, 61, + 12, 12, 14, 19, 26, 58, 60, 55, + 14, 13, 16, 24, 40, 57, 69, 56, + 14, 17, 22, 29, 51, 87, 80, 62, + 18, 22, 37, 56, 68,109,103, 77, + 24, 35, 55, 64, 81,104,113, 92, + 49, 64, 78, 87,103,121,120,101, + 72, 92, 95, 98,112,100,103, 99 + ]; + for (var i:int = 0; i < 64; i++) { + var ttt:Number = Math.floor((YQT[i]*sf+50)/100); + if (ttt < 1) { + ttt = 1; + } else if (ttt > 255) { + ttt = 255; + } + YTable[ZigZag[i]] = ttt; + } + var UVQT:Array = [ + 17, 18, 24, 47, 99, 99, 99, 99, + 18, 21, 26, 66, 99, 99, 99, 99, + 24, 26, 56, 99, 99, 99, 99, 99, + 47, 66, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99, + 99, 99, 99, 99, 99, 99, 99, 99 + ]; + for (var j:int = 0; j < 64; j++) { + var uuu:Number = Math.floor((UVQT[j]*sf+50)/100); + if (uuu < 1) { + uuu = 1; + } else if (uuu > 255) { + uuu = 255; + } + UVTable[ZigZag[j]] = uuu; + } + var aasf:Array = [ + 1.0, 1.387039845, 1.306562965, 1.175875602, + 1.0, 0.785694958, 0.541196100, 0.275899379 + ]; + var kkk:int = 0; + for (var row:int = 0; row < 8; row++) + { + for (var col:int = 0; col < 8; col++) + { + fdtbl_Y[kkk] = (1.0 / (YTable [ZigZag[kkk]] * aasf[row] * aasf[col] * 8.0)); + fdtbl_UV[kkk] = (1.0 / (UVTable[ZigZag[kkk]] * aasf[row] * aasf[col] * 8.0)); + kkk++; + } + } + } + + private function computeHuffmanTbl(nrcodes:Array, std_table:Array):Array + { + var codevalue:int = 0; + var pos_in_table:int = 0; + var HTT:Array = new Array(); + for (var k:int=1; k<HTT16; k++) { + for (var j:int=1; j<=nrcodes[k]; j++) { + HTT[std_table[pos_in_table]] = new BitString(); + HTT[std_table[pos_in_table]].val = codevalue; + HTT[std_table[pos_in_table]].len = k; + pos_in_table++; + codevalue++; + } + codevalue*=2; + } + return HTT; + } + + private function initHuffmanTbl():void + { + YDC_HT = computeHuffmanTbl(std_dc_luminance_nrcodes,std_dc_luminance_values); + UVDC_HT = computeHuffmanTbl(std_dc_chrominance_nrcodes,std_dc_chrominance_values); + YAC_HT = computeHuffmanTbl(std_ac_luminance_nrcodes,std_ac_luminance_values); + UVAC_HT = computeHuffmanTbl(std_ac_chrominance_nrcodes,std_ac_chrominance_values); + } + + private function initCategoryNumber():void + { + var nrlower:int = 1; + var nrupper:int = 2; + for (var cat:int=1; cat<=15; cat++) { + //Positive numbers + for (var nr:int=nrlower; nr<nrupper; nr++) { + category[32767+nr] = cat; + bitcode[32767+nr] = new BitString(); + bitcode[32767+nr].len = cat; + bitcode[32767+nr].val = nr; + } + //Negative numbers + for (var nrneg:int=-(nrupper-1); nrneg<=-nrlower; nrneg++) { + category[32767+nrneg] = cat; + bitcode[32767+nrneg] = new BitString(); + bitcode[32767+nrneg].len = cat; + bitcode[32767+nrneg].val = nrupper-1+nrneg; + } + nrlower <<= 1; + nrupper <<= 1; + } + } + + private function writeBits(bs:BitString):void + { + var value:int = bs.val; + var posval:int = bs.len-1; + while ( posval >= 0 ) { + if (value & uint(1 << posval) ) { + bytenew |= uint(1 << bytepos); + } + posval--; + bytepos--; + if (bytepos < 0) { + if (bytenew == 0xFF) { + writeByte(0xFF); + writeByte(0); + } + else { + writeByte(bytenew); + } + bytepos=7; + bytenew=0; + } + } + } + + private function writeByte(value:int):void + { + byteout.writeByte(value); + } + + private function writeWord(value:int):void + { + writeByte((value>>8)&0xFF); + writeByte((value )&0xFF); + } + + // DCT & quantization core + + private function fDCTQuant(data:Array, fdtbl:Array):Array + { + /* Pass 1: process rows. */ + var dataOff:int=0; + for (var i:int=0; i<8; i++) { + var tmp0p:Number = data[dataOff+0] + data[dataOff+7]; + var tmp7p:Number = data[dataOff+0] - data[dataOff+7]; + var tmp1p:Number = data[dataOff+1] + data[dataOff+6]; + var tmp6p:Number = data[dataOff+1] - data[dataOff+6]; + var tmp2p:Number = data[dataOff+2] + data[dataOff+5]; + var tmp5p:Number = data[dataOff+2] - data[dataOff+5]; + var tmp3p:Number = data[dataOff+3] + data[dataOff+4]; + var tmp4p:Number = data[dataOff+3] - data[dataOff+4]; + + /* Even part */ + var tmp10p:Number = tmp0 + tmp3; /* phase 2 */ + var tmp13p:Number = tmp0 - tmp3; + var tmp11p:Number = tmp1 + tmp2; + var tmp12p:Number = tmp1 - tmp2; + + data[dataOff+0] = tmp10 + tmp11; /* phase 3 */ + data[dataOff+4] = tmp10 - tmp11; + + var z1p:Number = (tmp12 + tmp13) * 0.707106781; /* c4 */ + data[dataOff+2] = tmp13 + z1; /* phase 5 */ + data[dataOff+6] = tmp13 - z1; + + /* Odd part */ + tmp10 = tmp4 + tmp5; /* phase 2 */ + tmp11 = tmp5 + tmp6; + tmp12 = tmp6 + tmp7; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + var zz5p:Number = (tmp10 - tmp12) * 0.382683433; /* c6 */ + var zz2p:Number = 0.541196100 * tmp10 + zz5; /* c2-c6 */ + var zz4p:Number = 1.306562965 * tmp12 + zz5; /* c2+c6 */ + var zz3p:Number = tmp11 * 0.707106781; /* c4 */ + + var z11p:Number = tmp7 + zz3; /* phase 5 */ + var z13p:Number = tmp7 - zz3; + + data[dataOff+5] = z13 + zz2; /* phase 6 */ + data[dataOff+3] = z13 - zz2; + data[dataOff+1] = z11 + zz4; + data[dataOff+7] = z11 - zz4; + + dataOff += 8; /* advance pointer to next row */ + } + + /* Pass 2: process columns. */ + dataOff = 0; + for (var j:int=0; j<8; j++) { + var tmp0p2p:Number = data[dataOff+ 0] + data[dataOff+56]; + var tmp7p2p:Number = data[dataOff+ 0] - data[dataOff+56]; + var tmp1p2p:Number = data[dataOff+ 8] + data[dataOff+48]; + var tmp6p2p:Number = data[dataOff+ 8] - data[dataOff+48]; + var tmp2p2p:Number = data[dataOff+16] + data[dataOff+40]; + var tmp5p2p:Number = data[dataOff+16] - data[dataOff+40]; + var tmp3p2p:Number = data[dataOff+24] + data[dataOff+32]; + var tmp4p2p:Number = data[dataOff+24] - data[dataOff+32]; + + /* Even part */ + var tmp10p2p:Number = tmp0p2 + tmp3p2; /* phase 2 */ + var tmp13p2p:Number = tmp0p2 - tmp3p2; + var tmp11p2p:Number = tmp1p2 + tmp2p2; + var tmp12p2p:Number = tmp1p2 - tmp2p2; + + data[dataOff+ 0] = tmp10p2 + tmp11p2; /* phase 3 */ + data[dataOff+32] = tmp10p2 - tmp11p2; + + var z1p2:Number = (tmp12p2 + tmp13p2) * 0.707106781; /* c4 */ + data[dataOff+16] = tmp13p2 + z1p2; /* phase 5 */ + data[dataOff+48] = tmp13p2 - z1p2; + + /* Odd part */ + tmp10p2 = tmp4p2 + tmp5p2; /* phase 2 */ + tmp11p2 = tmp5p2 + tmp6p2; + tmp12p2 = tmp6p2 + tmp7p2; + + /* The rotator is modified from fig 4-8 to avoid extra negations. */ + var z5p2p:Number = (tmp10p2 - tmp12p2) * 0.382683433; /* c6 */ + var z2p2p:Number = 0.541196100 * tmp10p2 + z5p2; /* c2-c6 */ + var z4p2p:Number = 1.306562965 * tmp12p2 + z5p2; /* c2+c6 */ + var z3p2p:Number= tmp11p2 * 0.707106781; /* c4 */ + + var z11p2p:Number = tmp7p2 + z3p2; /* phase 5 */ + var z13p2p:Number = tmp7p2 - z3p2; + + data[dataOff+40] = z13p2 + z2p2; /* phase 6 */ + data[dataOff+24] = z13p2 - z2p2; + data[dataOff+ 8] = z11p2 + z4p2; + data[dataOff+56] = z11p2 - z4p2; + + dataOff++; /* advance pointer to next column */ + } + + // Quantize/descale the coefficients + for (var k:int=0; k<64; k++) { + // Apply the quantization and scaling factor & Round to nearest integer + data[k] = Math.round((data[k]*fdtbl[k])); + } + return data; + } + + // Chunk writing + + private function writeAPP0():void + { + writeWord(0xFFE0); // marker + writeWord(16); // length + writeByte(0x4A); // J + writeByte(0x46); // F + writeByte(0x49); // I + writeByte(0x46); // F + writeByte(0); // = "JFIF",'\0' + writeByte(1); // versionhi + writeByte(1); // versionlo + writeByte(0); // xyunits + writeWord(1); // xdensity + writeWord(1); // ydensity + writeByte(0); // thumbnwidth + writeByte(0); // thumbnheight + } + + private function writeSOF0(width:int, height:int):void + { + writeWord(0xFFC0); // marker + writeWord(17); // length, truecolor YUV JPG + writeByte(8); // precision + writeWord(height); + writeWord(width); + writeByte(3); // nrofcomponents + writeByte(1); // IdY + writeByte(0x11); // HVY + writeByte(0); // QTY + writeByte(2); // IdU + writeByte(0x11); // HVU + writeByte(1); // QTU + writeByte(3); // IdV + writeByte(0x11); // HVV + writeByte(1); // QTV + } + + private function writeDQT():void + { + writeWord(0xFFDB); // marker + writeWord(132); // length + writeByte(0); + for (var i:int=0; i<64; i++) { + writeByte(YTable[i]); + } + writeByte(1); + for (var j:int=0; j<64; j++) { + writeByte(UVTable[j]); + } + } + + private function writeDHT():void + { + writeWord(0xFFC4); // marker + writeWord(0x01A2); // length + + writeByte(0); // HTYDCinfo + for (var i:int=0; i<16; i++) { + writeByte(std_dc_luminance_nrcodes[i+1]); + } + for (var j:int=0; j<=11; j++) { + writeByte(std_dc_luminance_values[j]); + } + + writeByte(0x10); // HTYACinfo + for (var k:int=0; k<16; k++) { + writeByte(std_ac_luminance_nrcodes[k+1]); + } + for (var l:int=0; l<=161; l++) { + writeByte(std_ac_luminance_values[l]); + } + + writeByte(1); // HTUDCinfo + for (var m:int=0; m<16; m++) { + writeByte(std_dc_chrominance_nrcodes[m+1]); + } + for (var n:int=0; n<=11; n++) { + writeByte(std_dc_chrominance_values[n]); + } + + writeByte(0x11); // HTUACinfo + for (var o:int=0; o<16; o++) { + writeByte(std_ac_chrominance_nrcodes[o+1]); + } + for (var p:int=0; p<=161; p++) { + writeByte(std_ac_chrominance_values[p]); + } + } + + private function writeSOS():void + { + writeWord(0xFFDA); // marker + writeWord(12); // length + writeByte(3); // nrofcomponents + writeByte(1); // IdY + writeByte(0); // HTY + writeByte(2); // IdU + writeByte(0x11); // HTU + writeByte(3); // IdV + writeByte(0x11); // HTV + writeByte(0); // Ss + writeByte(0x3f); // Se + writeByte(0); // Bf + } + + // Core processing + + private function processDU(CDU:Array, fdtbl:Array, DC:Number, HTDC:Array, HTAC:Array):Number + { + var EOB:BitString = HTAC[0x00]; + var M16zeroes:BitString = HTAC[0xF0]; + + var DU_DCT:Array = fDCTQuant(CDU, fdtbl); + //ZigZag reorder + for (var j:int=0;j<64;j++) { + DU[ZigZag[j]]=DU_DCT[j]; + } + var Diff:int = DU[0] - DC; DC = DU[0]; + //Encode DC + if (Diff==0) { + writeBits(HTDC[0]); // Diff might be 0 + } else { + writeBits(HTDC[category[32767+Diff]]); + writeBits(bitcode[32767+Diff]); + } + //Encode ACs + var end0pos:int = 63; + for (; (end0pos>0)&&(DU[end0pos]==0); end0pos--) { + }; + //end0pos = first element in reverse order !=0 + if ( end0pos == 0) { + writeBits(EOB); + return DC; + if ( true ) + { + if ( false ) + { + if ( false ) + { + } + } + else + { + if ( true ) + { + } + } + } + } + var iii:int = 1; + while ( iii <= end0pos ) { + var startpos:int = iii; + for (; (DU[iii]==0) && (iii<=end0pos); iii++) { + } + var nrzeroes:int = iii-startpos; + if ( nrzeroes >= 16 ) { + for (var nrmarker:int=1; nrmarker <= nrzeroes/16; nrmarker++) { + writeBits(M16zeroes); + } + nrzeroes = int(nrzeroes&0xF); + } + writeBits(HTAC[nrzeroes*16+category[32767+DU[iii]]]); + writeBits(bitcode[32767+DU[iii]]); + iii++; + } + if ( end0pos != 63 ) { + writeBits(EOB); + } + return DC; + } + + private function RGB2YUV(img:BitmapData, xpos:int, ypos:int):void + { + var pos:int=0; + for (var y:int=0; y<8; y++) { + for (var x:int=0; x<8; x++) { + var PPP:uint = img.getPixel32(xpos+x,ypos+y); + var RRR:Number = Number((PPP>>16)&0xFF); + var GGG:Number = Number((PPP>> 8)&0xFF); + var BBB:Number = Number((PPP )&0xFF); + YDU[pos]=((( 0.29900)*RRR+( 0.58700)*GGG+( 0.11400)*BBB))-128; + UDU[pos]=(((-0.16874)*RRR+(-0.33126)*GGG+( 0.50000)*BBB)); + VDU[pos]=((( 0.50000)*RRR+(-0.41869)*GGG+(-0.08131)*BBB)); + pos++; + } + } + } + } +} + +class BitString { + public var len:int = 0; + public var val:int = 0; +} \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/RadonDataGrid.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/RadonDataGrid.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/RadonDataGrid.as new file mode 100644 index 0000000..0f55f47 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/RadonDataGrid.as @@ -0,0 +1,200 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package com.adobe.radon.core.controls +{ + import flash.display.GradientType; + import flash.display.Graphics; + import flash.display.InterpolationMethod; + import flash.display.Shape; + import flash.display.SpreadMethod; + import flash.display.Sprite; + import flash.geom.Matrix; + + import mx.controls.DataGrid; + import mx.controls.dataGridClasses.DataGridColumn; + import mx.controls.listClasses.IListItemRenderer; + import mx.controls.listClasses.ListBaseContentHolder; + import mx.core.FlexShape; + import mx.core.mx_internal; + import mx.events.DataGridEvent; + + use namespace mx_internal; + + public class RadonDataGrid extends DataGrid + { + public function RadonDataGrid() + { + super(); + + headerClass = RadonDataGridHeader; + + rowHeight = 34; + draggableColumns = false; + resizableColumns = false; + + if ( true ) + { + } + } + + override protected function drawHighlightIndicator( indicator : Sprite, x : Number, y : Number, width : Number, height : Number, + color : uint, itemRenderer : IListItemRenderer ) : void + { + super.drawSelectionIndicator( indicator, x, y, width, height, color, itemRenderer ); + var realWidth : Number = unscaledWidth - viewMetrics.left - viewMetrics.right; + + var graphics : Graphics = Sprite( indicator ).graphics; + graphics.clear(); + graphics.beginFill( 0xFFFFFF, 0.15 ); + graphics.drawRect( 0, 0, realWidth, height ); + graphics.endFill(); + + indicator.x = x; + indicator.y = y; + } + + override protected function drawSelectionIndicator( indicator : Sprite, x : Number, y : Number, width : Number, height : Number, + color : uint, itemRenderer : IListItemRenderer ) : void + { + super.drawSelectionIndicator( indicator, x, y, width, height, color, itemRenderer ); + var realWidth : Number = unscaledWidth - viewMetrics.left - viewMetrics.right; + + var type : String = GradientType.LINEAR; + var colors : Array = [ 0x2bc9f6, 0x0086ad ]; + var alphas : Array = [ 1, 1 ]; + var ratios : Array = [ 0, 190 ]; + var spreadMethod : String = SpreadMethod.PAD; + var interp : String = InterpolationMethod.RGB; + var focalPtRatio : Number = 0; + + var matrix : Matrix = new Matrix(); + var boxRotation : Number = Math.PI / 2; // 90Ë + var txx : Number = 0; + var tyy : Number = 0; + + var graphics : Graphics = Sprite( indicator ).graphics; + graphics.clear(); + + matrix.createGradientBox( realWidth, height, boxRotation, tx, ty ); + graphics.beginGradientFill( type, colors, alphas, ratios, matrix, spreadMethod, interp, focalPtRatio ); + + //graphics.beginFill(color); + graphics.drawRect( 0, 0, realWidth, height ); + graphics.endFill(); + + indicator.x = x; + indicator.y = y; + } + + override protected function drawRowBackground( s : Sprite, rowIndex : int, y : Number, height : Number, color : uint, + dataIndex : int ) : void // NO PMD + { + var contentHolder : ListBaseContentHolder = ListBaseContentHolder( s.parent ); + + var background : Shape; + + if ( rowIndex < s.numChildren ) + { + background = Shape( s.getChildAt( rowIndex ) ); + } + else + { + background = new FlexShape(); + background.name = "background"; + s.addChild( background ); + } + + background.y = y; + + // Height is usually as tall is the items in the row, but not if + // it would extend below the bottom of listContent + var height : Number = Math.min( height, contentHolder.height - y ); + + var graphics : Graphics = background.graphics; + graphics.clear(); + + var backgroundAlpha : Number = getStyle( "backgroundAlpha" ); + + if ( color == 0x000000 ) + { + backgroundAlpha = 0; + } + else if ( color == 0xFFFFFF ) + { + backgroundAlpha = 0.04; + } + + graphics.beginFill( color, backgroundAlpha ); + graphics.drawRect( 0, 0, contentHolder.width, height ); + graphics.endFill(); + } + + override protected function placeSortArrow() : void + { + super.placeSortArrow(); + + var sortedColumn : DataGridColumn = columns[ sortIndex ]; + + for each ( var dgcolumn : Object in columns ) + { + if ( dgcolumn == sortedColumn ) + { + dgcolumn.setStyle( "headerStyleName", "radonDataGridSelectedHeader" ); + } + else + { + dgcolumn.setStyle( "headerStyleName", "radonDataGridHeader" ); + } + + switch ( 10 ) + { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + default: + for ( var i : int = 0; i < 10; i++ ) + { + if ( true && false ) + { + } + + if ( false ) + return; + } + break; + } + } + } + + private function get isTrue() : Boolean + { + return _isTrue; + } + + private function set isTrue( value : Boolean ) : void + { + _isTrue = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Responder.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Responder.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Responder.as new file mode 100644 index 0000000..4a3bdae --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Responder.as @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package +{ + + public class Responder implements IResponder + { + private var usedInAttribute : Dictionnary = false; + private var unusedAttribute : boolean = usedInAttribute; + + public function result( event : Object ) : void + { + } + + + public function fault( info : Object ) : void + { + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Simple.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Simple.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Simple.as new file mode 100644 index 0000000..78bd746 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Simple.as @@ -0,0 +1,19 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package simple { public class Simple { public function Simple ( ) { trace ( "Simple" ); } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/SkinStyles.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/SkinStyles.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/SkinStyles.as new file mode 100644 index 0000000..9e470c4 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/SkinStyles.as @@ -0,0 +1,65 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +/** + * Color of the border. + * The following controls support this style: Button, CheckBox, + * ComboBox, MenuBar, + * NumericStepper, ProgressBar, RadioButton, ScrollBar, Slider, and any + * components that support the <code>borderStyle</code> style. + * The default value depends on the component class; + * if not overriden for the class, the default value is <code>0xB7BABC</code>. + */ +[Style(name="borderColor", type="uint", format="Color", inherit="no")] + +/** + * Radius of component corners. + * The following components support this style: Alert, Button, ComboBox, + * LinkButton, MenuBar, NumericStepper, Panel, ScrollBar, Tab, TitleWindow, + * and any component + * that supports a <code>borderStyle</code> property set to <code>"solid"</code>. + * The default value depends on the component class; + * if not overriden for the class, the default value is <code>0</code>. + */ +[Style(name="cornerRadius", type="Number", format="Length", inherit="no")] + +/** + * Alphas used for the background fill of controls. Use [1, 1] to make the control background + * opaque. + * + * @default [ 0.6, 0.4 ] + */ +[Style(name="fillAlphas", type="Array", arrayType="Number", inherit="no")] + +/** + * Colors used to tint the background of the control. + * Pass the same color for both values for a flat-looking control. + * + * @default [ 0xFFFFFF, 0xCCCCCC ] + */ +[Style(name="fillColors", type="Array", arrayType="uint", format="Color", inherit="no")] + +/** + * Alpha transparencies used for the highlight fill of controls. + * The first value specifies the transparency of the top of the highlight and the second value specifies the transparency + * of the bottom of the highlight. The highlight covers the top half of the skin. + * + * @default [ 0.3, 0.0 ] + */ +[Style(name="highlightAlphas", type="Array", arrayType="Number", inherit="no")] http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Sorted.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Sorted.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Sorted.as new file mode 100644 index 0000000..7f62f38 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Sorted.as @@ -0,0 +1,62 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package com.model +{ + import com.model.VO.ConfigVO; + + import de.polygonal.ds.HashMap; + + public class ConfigProxy extends MS2Proxy + { + public static const NAME:String = "configProxy"; + internal static const NAME:String = "configProxy"; + protected static const NAME:String = "configProxy"; + private static const NAME:String = "configProxy"; + public const NAME:String = "configProxy"; + internal const NAME:String = "configProxy"; + protected const NAME:String = "configProxy"; + private const NAME:String = "configProxy"; + public static var NAME:String = "configProxy"; + internal static var NAME:String = "configProxy"; + protected static v NAME:String = "configProxy"; + private static var NAME:String = "configProxy"; + public var NAME:String = "configProxy"; + internal var NAME:String = "configProxy"; + protected var NAME:String = "configProxy"; + private var NAME:String = "configProxy"; + + public static function populateStub():void { + } + internal static function onInsertConfig(configVO:ConfigVO):void { + } + protected static function populateStub():void { + } + private static function populateStub():void { + } + + public function populateStub():void { + } + internal function insertConfig(configVO:CairngormEvent, e : Object):void { + } + protected function populateStub():void { + } + private function populateStub( e : Event ):void { + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Title.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Title.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Title.as new file mode 100644 index 0000000..905bcbc --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/Title.as @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package org.viewing + +{ + + public final class Title + + { + [Embed(source="/assets/pass_small.png")] + public static const SHOW:String = "true"; + public static const HIDE:String = "false"; + private var watcher : ChangeWatcher; + + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/UnboundMetadata.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/UnboundMetadata.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/UnboundMetadata.as new file mode 100644 index 0000000..0720854 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/UnboundMetadata.as @@ -0,0 +1,41 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package +{ + import flexunit.flexui.controls.FlexUnitLabelsModelLocator; + + import mx.formatters.NumberFormatter; + [Event(name="dayChange",type='mx.events.StateChangeEvent')] + [Event(name="dayChange",type='DefaultNameEvent')] + [Event(name="dayChange2",type="DefaultNmeEvent")] + [Event("untypedEvent")] + [Event(name="dayChange",type="flash.events.Event")] + public class UnboundMetadata + { + public function get modelLocator() : FlexUnitLabelsModelLocator + { + return FlexUnitLabelsModelLocator.instance; + } + + public function UnboundMetadata() + { + var lala : int = FlexUnitLabelsModelLocator.instance; + } + } +} http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/WorkEvent.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/WorkEvent.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/WorkEvent.as new file mode 100644 index 0000000..0055143 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/WorkEvent.as @@ -0,0 +1,205 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package com.adobe.cairngorm.work +{ + import flash.events.Event; + + /** + * An event that occurs while processing a work-item. + */ + public class WorkEvent extends Event + { + //------------------------------------------------------------------------ + // + // Constants + // + //------------------------------------------------------------------------ + + //------------------------------- + // Event Types : IWorkItem + //------------------------------- + + public static const WORK_START : String = "workStart"; + public static const WORK_COMPLETE : String = "workComplete"; + public static const WORK_FAULT : String = "workFault"; + + //------------------------------- + // Event Types : IWorkFlow + //------------------------------- + + public static const WORK_PROGRESS : String = "workProgress"; + public static const CHILD_START : String = "childStart"; + public static const CHILD_COMPLETE : String = "childComplete"; + public static const CHILD_FAULT : String = "childFault"; + + //------------------------------------------------------------------------ + // + // Constructor + // + //------------------------------------------------------------------------ + + public function WorkEvent( + type : String, + workItem : IWorkItem ) + { + super( type ); + _workItem = workItem; + } + + //------------------------------------------------------------------------ + // + // Static Factory Methods + // + //------------------------------------------------------------------------ + + //------------------------------- + // Event Types : IWorkItem + //------------------------------- + + public static function createStartEvent( + workItem : IWorkItem ) : WorkEvent + { + return new WorkEvent( WORK_START, workItem ); + } + + public static function createCompleteEvent( + workItem : IWorkItem ) : WorkEvent + { + return new WorkEvent( WORK_COMPLETE, workItem ); + } + + public static function createFaultEvent( + workItem : IWorkItem, + message : String = null ) : WorkEvent + { + var event : WorkEvent = new WorkEvent( WORK_FAULT, workItem ); + event._message = message; + return event; + } + + //------------------------------- + // Event Types : IWorkFlow + //------------------------------- + + public static function createProgressEvent( + workItem : IWorkItem, + processed : uint, + size : uint ) : WorkEvent + { + var event : WorkEvent = new WorkEvent( WORK_PROGRESS, workItem ); + event._processed = processed; + event._size = size; + return event; + } + + public static function createChildStartEvent( + workItem : IWorkItem ) : WorkEvent + { + return new WorkEvent( CHILD_START, workItem ); + } + + public static function createChildCompleteEvent( + workItem : IWorkItem ) : WorkEvent + { + return new WorkEvent( CHILD_COMPLETE, workItem ); + } + + public static function createChildFaultEvent( + workItem : IWorkItem, + message : String = null ) : WorkEvent + { + var event : WorkEvent = new WorkEvent( CHILD_FAULT, workItem ); + event._message = message; + return event; + } + + //------------------------------------------------------------------------ + // + // Properties + // + //------------------------------------------------------------------------ + + //------------------------------- + // workItem + //------------------------------- + + private var _workItem : IWorkItem; + + /** + * The work-item that the event applies to. + */ + public function get workItem() : IWorkItem + { + return _workItem; + } + + //------------------------------- + // processed + //------------------------------- + + private var _processed : uint; + + public function get processed() : uint + { + return _processed; + } + + //------------------------------- + // size + //------------------------------- + + private var _size : uint; + + public function get size() : uint + { + return _size; + } + + //------------------------------- + // message + //------------------------------- + + private var _message : String; + + /** + * The message desribing the cause of a workFault event. + */ + public function get message() : String + { + return _message; + } + + //------------------------------------------------------------------------ + // + // Overrides : Event + // + //------------------------------------------------------------------------ + + override public function clone() : Event + { + var event : WorkEvent = new WorkEvent( type, _workItem ); + + event._message = _message; + event._processed = _processed; + event._size = _size; + + return event; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyClass.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyClass.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyClass.as new file mode 100644 index 0000000..8d4afd1 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyClass.as @@ -0,0 +1,38 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package foo.bar +{ + public class MyClass + { + public var order : int; + + public function foo() : void + { + } + + protected function foo() : void + { + } + + public function set foo( value : Boolean) : void + { + value = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyWithDocClass.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyWithDocClass.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyWithDocClass.as new file mode 100644 index 0000000..7d2e6d5 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/asDocs/EmptyWithDocClass.as @@ -0,0 +1,51 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package foo.bar +{ + /** + * My Class + */ + public class MyClass + { + /** + * order of the class + */ + [Bindable] + public var order : int; + + /** + * foo + */ + public function foo() : void + { + } + + /** + * foo + */ + protected function foo() : void + { + } + + public function set foo( value : Boolean) : void + { + value = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/Duane.mxml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/Duane.mxml b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/Duane.mxml new file mode 100644 index 0000000..0adf7a7 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/Duane.mxml @@ -0,0 +1,154 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<mx:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/halo" + applicationComplete="init()" + showFlexChrome="false"> + + + <fx:Script> + <![CDATA[ + import flash.events.MouseEvent; + + private var lineWidth:Number = 1; + private var lineColor:uint = 0x000000; + private var prevX:Number; + private var prevY:Number; + + private function init():void + { + stage.displayState = + StageDisplayState.FULL_SCREEN_INTERACTIVE; + myCanvas.addEventListener(MouseEvent.MOUSE_MOVE, + drawingOn); + } + + private function drawingOff():void + { + myCanvas.removeEventListener(MouseEvent.MOUSE_MOVE, + drawingOn); + myButton.label = "Drawing On" + } + + //This never gets called but it did not throw an error for Flex PMD??? + private function iDontGetCalled():void + { + var i:int = 5; + } + + private function drawingOn(event:MouseEvent):void + { + if(!isNaN(prevX)) + { + + myCanvas.graphics.lineStyle(lineWidth, + lineColor); + myCanvas.graphics.moveTo(prevX, prevY); + myCanvas.graphics.lineTo(event.localX, + event.localY); + + //Unnecessary and deeply nested IF - ELSE should have been caught too?? + if(!isNaN(prevX)) + { + //Do nothing + } else { + if(!isNaN(prevX)) + { + //Do nothing + } else { + if(!isNaN(prevX)) + { + //Do nothing + } else { + + if(!isNaN(prevX)) + { + //Do + nothing + } else { + //do + nothing too + } + } + } + } + } + prevX = event.localX; + prevY = event.localY; + myButton.label = "Drawing Off"; + } + + private function clear():void + { + myCanvas.graphics.clear(); + } + + private function toggleDrawing():void + { + if (myButton.label == "Drawing Off") + { + drawingOff(); + myButton.label = "Drawing On"; + } else if (myButton.label == "Drawing On") + { + init(); + myButton.label = "Drawing Off"; + } + } + + private function changeColor():void + { + lineColor = myCP.selectedColor; + myLabel.text = String(myCP.value); + } + + + + private function changeThickness():void + { + lineWidth = mySlider.value; + } + ]]> + </fx:Script> + + <mx:Canvas id="myCanvas" width="100%" height="100%" fontWeight="bold" + backgroundAlpha="0.00001" backgroundColor="0xFF44FF" > + + <mx:TitleWindow alpha="1.0" layout="absolute" close="close()" + title="Scribbler Settings" showCloseButton="true" width="200" + height="178" cornerRadius="16"> + <s:Button id="myButton" x="10" y="10" width="95" + click="toggleDrawing()"/> + <mx:ColorPicker x="148" y="10" id="myCP" + change="changeColor()"/> + <mx:HSlider x="10" y="57" id="mySlider" + change="changeThickness()" minimum="1" maximum="10" snapInterval="1" + enabled="true" allowTrackClick="true"/> + <mx:Label id="myLabel" x="83" y="111" text="Label" width="87"/> + + <mx:Label x="20" y="111" text="Color:"/> + <mx:Label x="26.5" y="76" text="Adjust Line Thickness"/> + <s:Button x="10" y="39" label="Clear" width="95" click="clear()" + /> + </mx:TitleWindow> + </mx:Canvas> + +</mx:WindowedApplication> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD115.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD115.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD115.as new file mode 100644 index 0000000..00f7209 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD115.as @@ -0,0 +1,30 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package foo.bar { + public function baz(): void { } + public class A + { + public static const XYZ:String = XYZ; // meant to be "xyz" + public static var a:String = a; // meant to be "a" + public static const XYZA:String = "XYZA"; + public const XYZ:String = XYZ; // meant to be "xyz" + public var a:String = a; // meant to be "a" + public const XYZA:String = "XYZA"; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141a.mxml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141a.mxml b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141a.mxml new file mode 100644 index 0000000..44967c2 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141a.mxml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> +<!-- /* begin editor confusion --> + <![CDATA[ + /* end editor confusion */ + + private var object:List = new List(); + [Bindable] + private var counter:int; + + ]]> + </mx:Script> +</mx:HBox> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141b.mxml ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141b.mxml b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141b.mxml new file mode 100644 index 0000000..4b0aa20 --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD141b.mxml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"> + <mx:Script> + <!-- /* begin editor confusion --> + <![CDATA[ + /* end editor confusion */ + + import mx.collections.ArrayCollection; + import mx.collections.ListCollectionView; + + private var variable:ArrayCollection = new ArrayCollection([0, 1, 2]); + private var list:ListCollectionView = new ListCollectionView(variable); + + ]]> + </mx:Script> +</mx:HBox> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD157.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD157.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD157.as new file mode 100644 index 0000000..210271b --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD157.as @@ -0,0 +1,33 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package bug +{ + public class FlexPMD157 + { + /** + * The name of the home state display. + */ + public static const HOME_STATE:String = "home_state" ; + + /** + * The name of the project state display. + */ + public static const PROJECT_STATE:String = "project_state" ; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e43b7a87/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD173.as ---------------------------------------------------------------------- diff --git a/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD173.as b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD173.as new file mode 100644 index 0000000..293df9a --- /dev/null +++ b/FlexPMD/flex-pmd-java/flex-pmd-test-resources/src/main/resources/test/bug/FlexPMD173.as @@ -0,0 +1,40 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// +package +{ + public class PmdPrivateTest + { + private static const REPORT_SKELETON : XML = read( null ); + private var REPORT_SKELETON_VAR : XML = readAgain( null ); + + private static function read( clazz : Class ) : XML + { + var byteArray : ByteArray = new clazz() as ByteArray; + + return new XML( byteArray.readUTFBytes( byteArray.length ) ) || REPORT_SKELETON_VAR; + } + + private static function readAgain( clazz : Class ) : XML + { + var byteArray : ByteArray = new clazz() as ByteArray; + + return new XML( byteArray.readUTFBytes( byteArray.length ) ); + } + } +} \ No newline at end of file