Uploaded image for project: 'Appcelerator Studio'
  1. Appcelerator Studio
  2. TISTUD-3495

JSLint: Validation rules does not match - (too intermittent)

    Details

    • Type: Bug
    • Status: Open
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: Titanium Studio 3.0.1
    • Fix Version/s: None
    • Component/s: JS, Validation
    • Environment:

      Ti Studio 3.0.1.201212181159
      Titanium SDK: Mobile 2.1.4 and 3.x branch

      Description

      Problem

      The problem is that JSLint randomly reports warnings and errors on code that has absolutely no errors or warning-worthy bits in it. The errors/warnings appear seemingly randomly and then usually disappear when I add a new empty line (that in no way changes the semantics of the code) by hitting enter.

      Since at least version 2.1.2.201208301612 of Titanium Studio JSLint threw incorrect warnings or errors. Current version is 3.0.1.201212181159 though.

      text of the error

      Please see false-alarm-1b.png and false-alarm-1c.png screenshots

      what is enabled

      Only JSLint, for both build and reconcile, please see validation-settings-1a.png and validation-settings-1b.png.

      where the error/warning is coming from

      Only JSLint is enabled.

      JSLint settings in Studio

      {
        "white": true,
        "nomen": true,
        "vars": true,
        "undef": false,
        "sloppy": true,
        "plusplus": true,
        "laxLineEnd": true,
        "browser": true,
        "jscript": true,
        "debug": true,
        "maxerr": 100000,
        "white": true,
        "predef": [
          "Ti",
          "Titanium",
          "alert",
          "require",
          "exports",
          "native",
          "implements",
        ]
      }
      

      Sample file

      Errors or warning were reported on the following CommonJS file:

      var FILE_TRANSFER_UUID, BluetoothControlPanel;
       
      BluetoothControlPanel = require('bluetooth_control_panel');
       
      FILE_TRANSFER_UUID = '2ACC6F50-6113-11E2-BCFD-0800200C9A67';
       
      function DetailView() {
      	var self,
      	buttonParent, imageSelectorButton, imageSenderButton, imageLoaderButton,
      	imageViewParent, sendingImageView, receivingImageView,
      	controlPanel, remainingReceiveBytes, receiveBuffer;
      	
      	function send(imageBlob) {
      		var i, socket, stream, buffer, byteCount;
      		
      		if (controlPanel.isConnected()) {
      			socket = controlPanel.getClientSocket();
      		} else {
      			Ti.API.warn('Need to connect before sending.');
      			return;
      		}
      		
      		Ti.API.info('imageBlob size: ' + imageBlob.length);
      		stream = Ti.Stream.createStream({
      			mode: Ti.Stream.MODE_READ,
      			source: imageBlob
      		});
      		buffer = Ti.createBuffer({
      			length: imageBlob.length + 4
      		});
      		
      		byteCount = imageBlob.length;
      		for(i=3; i>-1; i--) {
      			buffer[i] = byteCount % 256;
      			byteCount = byteCount / 256;
      		}
      		stream.read(buffer, 4, imageBlob.length);
      		
      		socket.write(buffer);
      	}
      	
      	function loadImage() {
      		
      	}
      	
      	function handleReceivedData(e) {
      		var i;
      		
      		Ti.API.info('ZZZZ entering handleReceivedData');
      		if (remainingReceiveBytes) {
      			receiveBuffer.append(e.data);
      			remainingReceiveBytes -= e.data.length;
      			if (remainingReceiveBytes <= 0) {
      				receivingImageView.image = receiveBuffer.toBlob();
      				remainingReceiveBytes = 0;
      			}
      		} else {
      			remainingReceiveBytes = 0;
      			receiveBuffer = Ti.createBuffer();
      			
      			for(i=0; i<4; i++) {
      				remainingReceiveBytes *= 256;
      				remainingReceiveBytes += e.data[i];
      			}
      			if (e.data.length > 4) {
      				receiveBuffer.append(e.data, 4);
      			}
      		}
      	}
       
      	self = Ti.UI.createView({
      		backgroundColor: 'black',
      		layout: 'vertical'
      	});
      	
      	controlPanel = BluetoothControlPanel.createControlPanel({
      		uuid: FILE_TRANSFER_UUID,
      		dataReceivedCallback: handleReceivedData
      	});
       
      	imageViewParent = Ti.UI.createView({
      		width: '100%', height: '45%'
      	});
      	
      	sendingImageView = Ti.UI.createImageView({
      		width: '45%', height: '100%', left: '2%',
      		borderColor: 'green', borderWidth: 1
      	});
      	
      	imageViewParent.add(sendingImageView);
      	
      	receivingImageView = Ti.UI.createImageView({
      		width: '45%', height: '100%', right: '2%',
      		borderColor: 'red', borderWidth: 1
      	});
      	
      	imageViewParent.add(receivingImageView);
      	
      	imageSelectorButton = Ti.UI.createButton({
      		width: '45%', height: '50%',
      		left: '2%', top: 0,
      		title: 'Select Local Image'
      	});
      	
      	imageSelectorButton.addEventListener('click', function(e) {
      		Ti.Media.openPhotoGallery({
      			success: function(e) {
      				sendingImageView.image = e.media;
      				send(e.media);
      			}
      		});
      	});
      	
      	imageSenderButton = Ti.UI.createButton({
      		width: '45%', height: '50%',
      		left: '2%', bottom: 0,
      		title: 'Send Local Image'
      	});
      	
      	imageSelectorButton.addEventListener('click', function(e) {
      		Ti.Media.openPhotoGallery({
      			success: function(e) {
      				sendingImageView.image = e.media;
      				send(e.media);
      			}
      		});
      	});
      	
      	imageLoaderButton = Ti.UI.createButton({
      		width: '45%', height: '50%', right: '2%',
      		title: 'Load Remote Image'
      	});
      	
      	imageSelectorButton.addEventListener('click', function(e) {
      		if (controlPanel.isConnected()) {
      			Ti.API.info('Loading remote image');
      		}
      	});
      	
      	buttonParent = Ti.UI.createView({
      		width: '100%', height: '20%'
      	});
      	
      	buttonParent.add(imageSelectorButton);
      	buttonParent.add(imageSenderButton);
      	buttonParent.add(imageLoaderButton);
      	
      	self.add(controlPanel.getView());
      	self.add(imageViewParent);
      	self.add(buttonParent);
      	return self;
      }
       
      module.exports = DetailView;
      

        Attachments

          Activity

            People

            • Assignee:
              cwilliams Christopher Williams
              Reporter:
              egomez Eduardo Gomez (Inactive)
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: