From 72a96e137049c5e23ade58702b3476d22a17e909 Mon Sep 17 00:00:00 2001 From: Chris Malley Date: Mon, 10 Jun 2019 16:57:15 -0600 Subject: [PATCH] lint fixes, #115 --- js/common/model/CollisionDetector.js | 4 ++-- js/common/model/GasPropertiesContainer.js | 10 ++++++---- js/common/model/GasPropertiesModel.js | 2 +- js/common/model/PressureGauge.js | 3 +-- js/common/model/PressureModel.js | 2 +- js/diffusion/model/DiffusionCollisionDetector.js | 8 ++++---- js/energy/view/HistogramNode.js | 2 +- js/ideal/view/AnimatedHeaterCoolerNode.js | 4 ++-- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/js/common/model/CollisionDetector.js b/js/common/model/CollisionDetector.js index c4960598..5980860d 100644 --- a/js/common/model/CollisionDetector.js +++ b/js/common/model/CollisionDetector.js @@ -134,8 +134,8 @@ define( require => { updateParticleContainerCollisions() { let numberOfParticleContainerCollisions = 0; for ( let i = 0; i < this.particleArrays.length; i++ ) { - numberOfParticleContainerCollisions += - doParticleContainerCollisions( this.particleArrays[ i ], this.container.bounds, this.container.leftWallVelocity ); + numberOfParticleContainerCollisions += doParticleContainerCollisions( this.particleArrays[ i ], + this.container.bounds, this.container.leftWallVelocity ); } return numberOfParticleContainerCollisions; } diff --git a/js/common/model/GasPropertiesContainer.js b/js/common/model/GasPropertiesContainer.js index 431906da..2b078a7d 100644 --- a/js/common/model/GasPropertiesContainer.js +++ b/js/common/model/GasPropertiesContainer.js @@ -45,8 +45,10 @@ define( require => { // @private minimum width of the lid, overlaps the left wall, in pm. this.minLidWidth = this.openingLeftInset + this.wallThickness; + const initialLidWidth = this.widthProperty.value - this.openingRightInset + this.wallThickness; + // @public width of the lid, in pm - this.lidWidthProperty = new NumberProperty( this.widthProperty.value - this.openingRightInset + this.wallThickness, { + this.lidWidthProperty = new NumberProperty( initialLidWidth, { // range changes dynamically with width of container isValidValue: value => ( value >= this.minLidWidth && value <= this.getMaxLidWidth() ), @@ -62,7 +64,7 @@ define( require => { // @public {number} desired width of the container, in pm. // Set this to animate width change with a speed limit. See #90. this.desiredWidth = this.widthProperty.value; - + // @private {number} previous location of the left wall this.previousLeft = this.left; } @@ -184,7 +186,7 @@ define( require => { if ( this.lidIsOnProperty.value ) { openingLeft = this.left - this.wallThickness + this.lidWidthProperty.value; - // Round to the nearest pm to avoid floating-point error, see https://github.com/phetsims/gas-properties/issues/63. + // Round to nearest pm to avoid floating-point error, see https://github.com/phetsims/gas-properties/issues/63 openingLeft = Util.roundSymmetric( openingLeft ); } else { @@ -199,7 +201,7 @@ define( require => { `\nthis.lidWidthProperty.value=${this.lidWidthProperty.value}` + `\nthis.openingLeftInset=${this.openingLeftInset}` ); - + return openingLeft; } diff --git a/js/common/model/GasPropertiesModel.js b/js/common/model/GasPropertiesModel.js index e3f2f121..62e24f17 100644 --- a/js/common/model/GasPropertiesModel.js +++ b/js/common/model/GasPropertiesModel.js @@ -353,7 +353,7 @@ define( require => { const T = this.temperatureModel.computeTemperature(); // temperature has not been updated, so compute it const P = this.pressureModel.pressureProperty.value / GasPropertiesConstants.PRESSURE_CONVERSION_SCALE; assert && assert( P !== 0, 'zero pressure not supported' ); - + return ( N * k * T ) / P; } diff --git a/js/common/model/PressureGauge.js b/js/common/model/PressureGauge.js index 712a3689..07c63f6e 100644 --- a/js/common/model/PressureGauge.js +++ b/js/common/model/PressureGauge.js @@ -142,5 +142,4 @@ define( require => { PressureGauge.Units = new Enumeration( [ 'KILOPASCALS', 'ATMOSPHERES' ] ); return gasProperties.register( 'PressureGauge', PressureGauge ); -} ); - \ No newline at end of file +} ); \ No newline at end of file diff --git a/js/common/model/PressureModel.js b/js/common/model/PressureModel.js index 9913ef1a..940f01cd 100644 --- a/js/common/model/PressureModel.js +++ b/js/common/model/PressureModel.js @@ -86,7 +86,7 @@ define( require => { */ update( dtPressureGauge, numberOfCollisions ) { - // When adding particles to an empty container, don't compute pressure until 1 particle has collided with the container. + // When adding particles to empty container, don't compute pressure until 1 particle has collided with container if ( !this.updatePressureEnabled && numberOfCollisions > 0 ) { this.updatePressureEnabled = true; } diff --git a/js/diffusion/model/DiffusionCollisionDetector.js b/js/diffusion/model/DiffusionCollisionDetector.js index 3fb9bba4..3f5bdec2 100644 --- a/js/diffusion/model/DiffusionCollisionDetector.js +++ b/js/diffusion/model/DiffusionCollisionDetector.js @@ -51,10 +51,10 @@ define( require => { // If the divider is in place, treat the 2 sides of the container as 2 separate containers. const leftWallVelocity = Vector2.ZERO; - numberOfParticleContainerCollisions += - CollisionDetector.doParticleContainerCollisions( this.particleArrays[ 0 ], this.container.leftBounds, leftWallVelocity ); - numberOfParticleContainerCollisions += - CollisionDetector.doParticleContainerCollisions( this.particleArrays[ 1 ], this.container.rightBounds, leftWallVelocity ); + numberOfParticleContainerCollisions += CollisionDetector.doParticleContainerCollisions( + this.particleArrays[ 0 ], this.container.leftBounds, leftWallVelocity ); + numberOfParticleContainerCollisions += CollisionDetector.doParticleContainerCollisions( + this.particleArrays[ 1 ], this.container.rightBounds, leftWallVelocity ); } else { diff --git a/js/energy/view/HistogramNode.js b/js/energy/view/HistogramNode.js index ec945898..1ff20fbc 100644 --- a/js/energy/view/HistogramNode.js +++ b/js/energy/view/HistogramNode.js @@ -129,7 +129,7 @@ define( require => { top: background.bottom + 5 } ) ); - // y-axis label + // y-axis label const yAxisLabelNode = new Text( yAxisString, _.extend( {}, HISTOGRAM_AXIS_LABEL_OPTIONS, { rotation: -Math.PI / 2, maxWidth: 0.9 * background.height, diff --git a/js/ideal/view/AnimatedHeaterCoolerNode.js b/js/ideal/view/AnimatedHeaterCoolerNode.js index 99cb088a..69f00f6e 100644 --- a/js/ideal/view/AnimatedHeaterCoolerNode.js +++ b/js/ideal/view/AnimatedHeaterCoolerNode.js @@ -42,7 +42,7 @@ define( require => { const MAX_DELTA_T_N = 20000; // Mapping of deltaT * N to heat factor. - const TO_HEAT_FACTOR = new LinearFunction( 0, MAX_DELTA_T_N, MIN_HEAT_COOL_FACTOR, 1, true /* clamp */ ); + const toHeatFactor = new LinearFunction( 0, MAX_DELTA_T_N, MIN_HEAT_COOL_FACTOR, 1, true /* clamp */ ); // Animations will be controlled by calling step const STEP_EMITTER = null; @@ -110,7 +110,7 @@ define( require => { // compute heat/cool factor, relative to temperature change and number of particles const deltaTN = deltaT * numberOfParticles; // deltaT * N - const heatCoolFactor = Util.sign( deltaT ) * TO_HEAT_FACTOR( Math.abs( deltaTN ) ); + const heatCoolFactor = Util.sign( deltaT ) * toHeatFactor( Math.abs( deltaTN ) ); assert && assert( heatCoolFactor >= -1 && heatCoolFactor <= 1, `invalid heatCoolFactor: ${heatCoolFactor}` ); // Animation that moves the flame/ice up