Skip to content

Commit

Permalink
Merge pull request #5481 from omh1280/no_else_return
Browse files Browse the repository at this point in the history
Enable `no-else-return` rule
  • Loading branch information
mramato authored Jun 19, 2017
2 parents f020d97 + 6cc37c7 commit 9aa65cd
Show file tree
Hide file tree
Showing 23 changed files with 117 additions and 139 deletions.
3 changes: 1 addition & 2 deletions Apps/Sandcastle/Sandcastle-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
return 'null';
} else if (defined(value)) {
return value.toString();
} else {
return 'undefined';
}
return 'undefined';
}

console.originalLog = console.log;
Expand Down
12 changes: 5 additions & 7 deletions Source/Core/CesiumTerrainProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,11 @@ define([
return {
Accept : 'application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01'
};
} else {
var extensions = extensionsList.join('-');
return {
Accept : 'application/vnd.quantized-mesh;extensions=' + extensions + ',application/octet-stream;q=0.9,*/*;q=0.01'
};
}
var extensions = extensionsList.join('-');
return {
Accept : 'application/vnd.quantized-mesh;extensions=' + extensions + ',application/octet-stream;q=0.9,*/*;q=0.01'
};
}

function createHeightmapTerrainData(provider, buffer, level, x, y, tmsY) {
Expand Down Expand Up @@ -552,9 +551,8 @@ define([
return when(promise, function(buffer) {
if (defined(that._heightmapStructure)) {
return createHeightmapTerrainData(that, buffer, level, x, y, tmsY);
} else {
return createQuantizedMeshTerrainData(that, buffer, level, x, y, tmsY);
}
return createQuantizedMeshTerrainData(that, buffer, level, x, y, tmsY);
});
};

Expand Down
26 changes: 12 additions & 14 deletions Source/Core/IntersectionTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,10 @@ define([
start : root1,
stop : root0
};
} else {
// qw2 == product. Repeated roots (2 intersections).
var root = Math.sqrt(difference / w2);
return new Interval(root, root);
}
// qw2 == product. Repeated roots (2 intersections).
var root = Math.sqrt(difference / w2);
return new Interval(root, root);
} else if (q2 < 1.0) {
// Inside ellipsoid (2 intersections).
difference = q2 - 1.0; // Negatively valued.
Expand All @@ -463,17 +462,16 @@ define([
discriminant = qw * qw - product;
temp = -qw + Math.sqrt(discriminant); // Positively valued.
return new Interval(0.0, temp / w2);
} else {
// q2 == 1.0. On ellipsoid.
if (qw < 0.0) {
// Looking inward.
w2 = Cartesian3.magnitudeSquared(w);
return new Interval(0.0, -qw / w2);
}

// qw >= 0.0. Looking outward or tangent.
return undefined;
}
// q2 == 1.0. On ellipsoid.
if (qw < 0.0) {
// Looking inward.
w2 = Cartesian3.magnitudeSquared(w);
return new Interval(0.0, -qw / w2);
}

// qw >= 0.0. Looking outward or tangent.
return undefined;
};

function addWithCancellationCheck(left, right, tolerance) {
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Intersections2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,8 @@ define([
result.y = l2;
result.z = l3;
return result;
} else {
return new Cartesian3(l1, l2, l3);
}
return new Cartesian3(l1, l2, l3);
};

return Intersections2D;
Expand Down
7 changes: 3 additions & 4 deletions Source/Core/Plane.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ define([

if (!defined(result)) {
return new Plane(normal, distance);
} else {
Cartesian3.clone(normal, result.normal);
result.distance = distance;
return result;
}
Cartesian3.clone(normal, result.normal);
result.distance = distance;
return result;
};

/**
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/QuantizedMeshTerrainData.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,8 @@ define([
if (needsSort) {
arrayScratch.sort(sortFunction);
return IndexDatatype.createTypedArray(vertexCount, arrayScratch);
} else {
return indices;
}
return indices;
}

var createMeshTaskProcessor = new TaskProcessor('createVerticesFromQuantizedTerrainMesh');
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/QuarticRealPolynomial.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,8 @@ define([
return [roots1[0], roots2[0], roots2[1], roots1[1]];
} else if (roots1[0] > roots2[0] && roots1[0] < roots2[1]) {
return [roots2[0], roots1[0], roots2[1], roots1[1]];
} else {
return [roots1[0], roots2[0], roots1[1], roots2[1]];
}
return [roots1[0], roots2[0], roots1[1], roots2[1]];
}
return roots1;
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Simon1994PlanetaryPositions.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ define([
return 'Elliptical';
} else if (eccentricity <= 1.0 + tolerance) {
return 'Parabolic';
} else {
return 'Hyperbolic';
}
return 'Hyperbolic';
}

// Calculates the true anomaly given the mean anomaly and the eccentricity.
Expand Down
16 changes: 7 additions & 9 deletions Source/Core/TerrainEncoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,20 @@ define([
offsetInBytes : numCompressed0 * sizeInBytes,
strideInBytes : stride
}];
} else {
return [{
index : attributes.compressed0,
vertexBuffer : buffer,
componentDatatype : datatype,
componentsPerAttribute : numCompressed0
}];
}
return [{
index : attributes.compressed0,
vertexBuffer : buffer,
componentDatatype : datatype,
componentsPerAttribute : numCompressed0
}];
};

TerrainEncoding.prototype.getAttributeLocations = function() {
if (this.quantization === TerrainQuantization.NONE) {
return attributesNone;
} else {
return attributes;
}
return attributes;
};

TerrainEncoding.clone = function(encoding, result) {
Expand Down
119 changes: 59 additions & 60 deletions Source/DataSources/CzmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,21 +265,21 @@ define([
scratchSpherical.cone = unitSpherical[1];
Cartesian3.fromSpherical(scratchSpherical, scratchCartesian);
return [scratchCartesian.x, scratchCartesian.y, scratchCartesian.z];
} else {
var result = new Array(length / 3 * 4);
for (var i = 0, j = 0; i < length; i += 3, j += 4) {
result[j] = unitSpherical[i];
}

scratchSpherical.clock = unitSpherical[i + 1];
scratchSpherical.cone = unitSpherical[i + 2];
Cartesian3.fromSpherical(scratchSpherical, scratchCartesian);
var result = new Array(length / 3 * 4);
for (var i = 0, j = 0; i < length; i += 3, j += 4) {
result[j] = unitSpherical[i];

result[j + 1] = scratchCartesian.x;
result[j + 2] = scratchCartesian.y;
result[j + 3] = scratchCartesian.z;
}
return result;
scratchSpherical.clock = unitSpherical[i + 1];
scratchSpherical.cone = unitSpherical[i + 2];
Cartesian3.fromSpherical(scratchSpherical, scratchCartesian);

result[j + 1] = scratchCartesian.x;
result[j + 2] = scratchCartesian.y;
result[j + 3] = scratchCartesian.z;
}
return result;
}

function convertSphericalToCartesian(spherical) {
Expand All @@ -290,22 +290,22 @@ define([
scratchSpherical.magnitude = spherical[2];
Cartesian3.fromSpherical(scratchSpherical, scratchCartesian);
return [scratchCartesian.x, scratchCartesian.y, scratchCartesian.z];
} else {
var result = new Array(length);
for (var i = 0; i < length; i += 4) {
result[i] = spherical[i];

scratchSpherical.clock = spherical[i + 1];
scratchSpherical.cone = spherical[i + 2];
scratchSpherical.magnitude = spherical[i + 3];
Cartesian3.fromSpherical(scratchSpherical, scratchCartesian);

result[i + 1] = scratchCartesian.x;
result[i + 2] = scratchCartesian.y;
result[i + 3] = scratchCartesian.z;
}
return result;
}

var result = new Array(length);
for (var i = 0; i < length; i += 4) {
result[i] = spherical[i];

scratchSpherical.clock = spherical[i + 1];
scratchSpherical.cone = spherical[i + 2];
scratchSpherical.magnitude = spherical[i + 3];
Cartesian3.fromSpherical(scratchSpherical, scratchCartesian);

result[i + 1] = scratchCartesian.x;
result[i + 2] = scratchCartesian.y;
result[i + 3] = scratchCartesian.z;
}
return result;
}

function convertCartographicRadiansToCartesian(cartographicRadians) {
Expand All @@ -316,22 +316,22 @@ define([
scratchCartographic.height = cartographicRadians[2];
Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic, scratchCartesian);
return [scratchCartesian.x, scratchCartesian.y, scratchCartesian.z];
} else {
var result = new Array(length);
for (var i = 0; i < length; i += 4) {
result[i] = cartographicRadians[i];

scratchCartographic.longitude = cartographicRadians[i + 1];
scratchCartographic.latitude = cartographicRadians[i + 2];
scratchCartographic.height = cartographicRadians[i + 3];
Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic, scratchCartesian);

result[i + 1] = scratchCartesian.x;
result[i + 2] = scratchCartesian.y;
result[i + 3] = scratchCartesian.z;
}
return result;
}

var result = new Array(length);
for (var i = 0; i < length; i += 4) {
result[i] = cartographicRadians[i];

scratchCartographic.longitude = cartographicRadians[i + 1];
scratchCartographic.latitude = cartographicRadians[i + 2];
scratchCartographic.height = cartographicRadians[i + 3];
Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic, scratchCartesian);

result[i + 1] = scratchCartesian.x;
result[i + 2] = scratchCartesian.y;
result[i + 3] = scratchCartesian.z;
}
return result;
}

function convertCartographicDegreesToCartesian(cartographicDegrees) {
Expand All @@ -342,22 +342,22 @@ define([
scratchCartographic.height = cartographicDegrees[2];
Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic, scratchCartesian);
return [scratchCartesian.x, scratchCartesian.y, scratchCartesian.z];
} else {
var result = new Array(length);
for (var i = 0; i < length; i += 4) {
result[i] = cartographicDegrees[i];

scratchCartographic.longitude = CesiumMath.toRadians(cartographicDegrees[i + 1]);
scratchCartographic.latitude = CesiumMath.toRadians(cartographicDegrees[i + 2]);
scratchCartographic.height = cartographicDegrees[i + 3];
Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic, scratchCartesian);

result[i + 1] = scratchCartesian.x;
result[i + 2] = scratchCartesian.y;
result[i + 3] = scratchCartesian.z;
}
return result;
}

var result = new Array(length);
for (var i = 0; i < length; i += 4) {
result[i] = cartographicDegrees[i];

scratchCartographic.longitude = CesiumMath.toRadians(cartographicDegrees[i + 1]);
scratchCartographic.latitude = CesiumMath.toRadians(cartographicDegrees[i + 2]);
scratchCartographic.height = cartographicDegrees[i + 3];
Ellipsoid.WGS84.cartographicToCartesian(scratchCartographic, scratchCartesian);

result[i + 1] = scratchCartesian.x;
result[i + 2] = scratchCartesian.y;
result[i + 3] = scratchCartesian.z;
}
return result;
}

function unwrapCartesianInterval(czmlInterval) {
Expand Down Expand Up @@ -496,10 +496,9 @@ define([
return Uri;
} else if (czmlInterval.hasOwnProperty('verticalOrigin')) {
return VerticalOrigin;
} else {
// fallback case
return Object;
}
// fallback case
return Object;
}

function unwrapInterval(type, czmlInterval, sourceUri, query) {
Expand Down
3 changes: 1 addition & 2 deletions Source/DataSources/KmlDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -2239,9 +2239,8 @@ define([
return loadKml(dataSource, entityCollection, kml, sourceUri, uriResolver, context, query);
});
});
} else {
return loadKml(dataSource, entityCollection, dataToLoad, sourceUri, uriResolver, context, query);
}
return loadKml(dataSource, entityCollection, dataToLoad, sourceUri, uriResolver, context, query);
})
.otherwise(function(error) {
dataSource._error.raiseEvent(dataSource, error);
Expand Down
4 changes: 2 additions & 2 deletions Source/DataSources/VelocityVectorProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ define([
var velocity = Cartesian3.subtract(position2, position1, velocityResult);
if (this._normalize) {
return Cartesian3.normalize(velocity, velocityResult);
} else {
return Cartesian3.divideByScalar(velocity, step, velocityResult);
}

return Cartesian3.divideByScalar(velocity, step, velocityResult);
};

/**
Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/GoogleEarthEnterpriseImageryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,8 @@ define([
});
metadata.populateSubtree(x, y, level, metadataRequest);
return undefined; // No metadata so return undefined so we can be loaded later
} else {
return invalidImage; // Image doesn't exist
}
return invalidImage; // Image doesn't exist
}

if (!info.hasImagery()) {
Expand Down
7 changes: 3 additions & 4 deletions Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1334,11 +1334,10 @@ define([
pan3D(controller, startPosition, movement, ellipsoid);
}
return;
} else {
controller._looking = false;
controller._rotating = false;
controller._strafing = false;
}
controller._looking = false;
controller._rotating = false;
controller._strafing = false;

if (defined(globe) && height < controller._minimumPickingTerrainHeight) {
if (defined(mousePos)) {
Expand Down
3 changes: 1 addition & 2 deletions Source/Scene/ShadowMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ define([
return ShadowMode.CAST_ONLY;
} else if (receiveShadows) {
return ShadowMode.RECEIVE_ONLY;
} else {
return ShadowMode.DISABLED;
}
return ShadowMode.DISABLED;
};

return freezeObject(ShadowMode);
Expand Down
Loading

0 comments on commit 9aa65cd

Please sign in to comment.