Skip to content

Commit 16f8caf

Browse files
committed
Remove unused getSortKey from DataValue interface
I'm trying to minimize the unused code in this repository for years. Today I finally found a string I can pull without the whole thing breaking apart: Just do a fultext search for "getSortKey" and you will see it is not used anywhere. This will allow us to remove much, much more unused code. I'm focusing on two very small methods here and plan to continue removing more unused code in later patches. * The iso6709 method on the class is unused now. Note there is an other static helper function with the same name and a parameter. That is still used. * _getTimestamp is private anyway. The parameter is unused now.
1 parent 170f11a commit 16f8caf

20 files changed

+30
-237
lines changed

DataValuesJavaScript.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
return 1;
88
}
99

10-
define( 'DATA_VALUES_JAVASCRIPT_VERSION', '0.8.4' );
10+
define( 'DATA_VALUES_JAVASCRIPT_VERSION', '0.9.0' );
1111

1212
// Include the composer autoloader if it is present.
1313
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ On [Packagist](https://packagist.org/packages/data-values/javascript):
1111

1212
## Release notes
1313

14+
### 0.9.0 (dev)
15+
* Removed `dataValues.DataValue.getSortKey` from the interface and all implementations.
16+
* Removed `globeCoordinate.GlobeCoordinate.iso6709`.
17+
1418
### 0.8.4 (2017-07-18)
1519
* Updated JSDoc tags mistakenly requiring objects.
1620
* Removed an unused dependency on `composer/installers`.

lib/globeCoordinate/globeCoordinate.GlobeCoordinate.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,6 @@
119119
};
120120
},
121121

122-
/**
123-
* Returns a coordinate's ISO 6709 string representation.
124-
* (see globeCoordinate.iso6709)
125-
*
126-
* @return {string}
127-
*/
128-
iso6709: function() {
129-
return globeCoordinate.iso6709( this.getDecimal() );
130-
},
131-
132122
/**
133123
* Compares the object to another GlobeCoordinate object and returns whether both represent
134124
* the same information.

lib/globeCoordinate/globeCoordinate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,4 @@ this.globeCoordinate = ( function() {
163163

164164
};
165165

166-
} )();
166+
} )();

src/DataValue.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,6 @@ $.extend( SELF.prototype, {
3838
*/
3939
getValue: util.abstractMember,
4040

41-
/**
42-
* Returns a key that can be used for sorting the data value.
43-
* Can be either numeric or a string.
44-
* NOTE: this could very well be set by the API, together with the value. Since the value is
45-
* immutable, this won't change as well and there is no need for having the logic here.
46-
* @abstract
47-
*
48-
* @return {string|number}
49-
*/
50-
getSortKey: util.abstractMember,
51-
5241
/**
5342
* Returns a simple JSON structure representing this data value.
5443
* @abstract

src/values/BoolValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,6 @@ var SELF = dv.BoolValue = util.inherit( 'DvBoolValue', PARENT, function( value )
2929
*/
3030
_value: null,
3131

32-
/**
33-
* @inheritdoc
34-
*
35-
* @return {number}
36-
*/
37-
getSortKey: function() {
38-
return this._value ? 1 : 0;
39-
},
40-
4132
/**
4233
* @inheritdoc
4334
*

src/values/DecimalValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,6 @@ var SELF = dv.DecimalValue = util.inherit( 'DvDecimalValue', PARENT, function( v
119119
*/
120120
_value: null,
121121

122-
/**
123-
* @inheritdoc
124-
*
125-
* @return {string}
126-
*/
127-
getSortKey: function() {
128-
return this._value;
129-
},
130-
131122
/**
132123
* @inheritdoc
133124
*

src/values/GlobeCoordinateValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ var SELF
3434
*/
3535
_value: null,
3636

37-
/**
38-
* @inheritdoc
39-
*
40-
* @return {string}
41-
*/
42-
getSortKey: function() {
43-
return this.getValue().iso6709();
44-
},
45-
4637
/**
4738
* @inheritdoc
4839
*

src/values/MonolingualTextValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ var SELF
3838
*/
3939
_text: null,
4040

41-
/**
42-
* @inheritdoc
43-
*
44-
* @return string
45-
*/
46-
getSortKey: function() {
47-
return this._languageCode + this._text;
48-
},
49-
5041
/**
5142
* @inheritdoc
5243
*

src/values/MultilingualTextValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ var SELF
3030
*/
3131
_texts: null,
3232

33-
/**
34-
* @inheritdoc
35-
*
36-
* @return {string}
37-
*/
38-
getSortKey: function() {
39-
return this._texts.length < 1 ? '' : this._texts[0].getSortKey();
40-
},
41-
4233
/**
4334
* @inheritdoc
4435
*

src/values/NumberValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,6 @@ var SELF = dv.NumberValue = util.inherit( 'DvNumberValue', PARENT, function( val
2525
*/
2626
_value: null,
2727

28-
/**
29-
* @inheritdoc
30-
*
31-
* @return {number}
32-
*/
33-
getSortKey: function() {
34-
return this._value;
35-
},
36-
3728
/**
3829
* @inheritdoc
3930
*

src/values/QuantityValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,6 @@ var SELF
7171
*/
7272
_upperBound: null,
7373

74-
/**
75-
* @inheritdoc
76-
*
77-
* @return {string}
78-
*/
79-
getSortKey: function() {
80-
return this._amount.getValue();
81-
},
82-
8374
/**
8475
* @inheritdoc
8576
*

src/values/StringValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,6 @@ var SELF = dv.StringValue = util.inherit( 'DvStringValue', PARENT, function( val
3030
*/
3131
_value: null,
3232

33-
/**
34-
* @inheritdoc
35-
*
36-
* @return {string}
37-
*/
38-
getSortKey: function() {
39-
return this._value;
40-
},
41-
4233
/**
4334
* @inheritdoc
4435
*

src/values/TimeValue.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,6 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( timesta
124124
return this._options[key];
125125
},
126126

127-
/**
128-
* @inheritdoc
129-
*
130-
* @return {string}
131-
*/
132-
getSortKey: function() {
133-
return this._getTimestamp( true );
134-
},
135-
136127
/**
137128
* @inheritdoc
138129
*
@@ -220,14 +211,11 @@ var SELF = dv.TimeValue = util.inherit( 'DvTimeValue', PARENT, function( timesta
220211
/**
221212
* @private
222213
*
223-
* @param {boolean} [padYear=false] True if the year should be padded to the maximum length of
224-
* 16 digits, false for the default padding to 4 digits.
225-
*
226214
* @return {string} A YMD-ordered timestamp string resembling ISO 8601.
227215
*/
228-
_getTimestamp: function( padYear ) {
216+
_getTimestamp: function() {
229217
return ( this._time.year.charAt( 0 ) === '-' ? '-' : '+' )
230-
+ pad( this._time.year, padYear ? 16 : 4 ) + '-'
218+
+ pad( this._time.year, 4 ) + '-'
231219
+ pad( this._time.month, 2 ) + '-'
232220
+ pad( this._time.day, 2 ) + 'T'
233221
+ pad( this._time.hour, 2 ) + ':'

src/values/UnDeserializableValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ var SELF = dv.UnDeserializableValue = util.inherit(
5757
*/
5858
_deserializeError: null,
5959

60-
/**
61-
* @inheritdoc
62-
*
63-
* @return {string}
64-
*/
65-
getSortKey: function() {
66-
return this.getReason();
67-
},
68-
6960
/**
7061
* @inheritdoc
7162
*

src/values/UnknownValue.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,6 @@ var SELF = dv.UnknownValue = util.inherit( 'DvUnknownValue', PARENT, function( v
2424
*/
2525
_value: null,
2626

27-
/**
28-
* @inheritdoc
29-
*
30-
* @return {number}
31-
*/
32-
getSortKey: function() {
33-
return 0;
34-
},
35-
3627
/**
3728
* @inheritdoc
3829
*

tests/lib/globeCoordinate/globeCoordinate.Formatter.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ define( [
1818
'1, 1': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),
1919
'-10, -1.5': new GlobeCoordinate( { latitude: -10, longitude: -1.5, precision: 0.1 } ),
2020
'20, 0': new GlobeCoordinate( { latitude: 24, longitude: -1.5, precision: 10 } ),
21-
'15, 20' : new GlobeCoordinate( { latitude: 15, longitude: 20 } )
21+
'15, 20': new GlobeCoordinate( { latitude: 15, longitude: 20 } )
2222
},
2323
degreeTexts= {
2424
'1°N, 1°E': new GlobeCoordinate( { latitude: 1, longitude: 1, precision: 1 } ),

tests/lib/globeCoordinate/globeCoordinate.GlobeCoordinate.tests.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,6 @@ define( [
7070
{ latitude: 1.5, longitude: 1.5, precision: 0.1 },
7171
'Verified getDecimal()'
7272
);
73-
74-
assert.equal(
75-
typeof c.iso6709(),
76-
'string',
77-
'Verified iso6709()'
78-
);
7973
} );
8074

8175
QUnit.test( 'Precision defaults to null', function( assert ) {
@@ -119,36 +113,6 @@ define( [
119113
);
120114
} );
121115

122-
QUnit.test( 'ISO 6709 strings', function( assert ) {
123-
assert.expect( 12 );
124-
var gcDefs = [
125-
{ precision: 10, expected: '+10+010/' },
126-
{ precision: 2, expected: '+14+012/' },
127-
{ precision: 1, expected: '+13+012/' },
128-
{ precision: 0.1, expected: '+1307+01207/' },
129-
{ precision: 0.01, expected: '+130724+0120724/' },
130-
{ precision: 1 / 60, expected: '+1307+01207/' },
131-
{ precision: 1 / 3600, expected: '+130724+0120724/' },
132-
{ precision: 1 / 36000, expected: '+130724.4+0120724.4/' },
133-
{ precision: 1 / 360000, expected: '+130724.42+0120724.42/' },
134-
{ precision: 0, expected: '+130724.42+0120724.42/' },
135-
{ precision: null, expected: '+130724.42+0120724.42/' },
136-
{ expected: '+130724.42+0120724.42/' }
137-
],
138-
c;
139-
140-
$.each( gcDefs, function( i, gcDef ) {
141-
c = new globeCoordinate.GlobeCoordinate(
142-
{ latitude: 13.12345, longitude: 12.12345, precision: gcDef.precision }
143-
);
144-
145-
assert.ok(
146-
c.iso6709() === gcDef.expected,
147-
'Validated ISO 6709 string of data set #' + i + '.'
148-
);
149-
} );
150-
} );
151-
152116
QUnit.test( 'Strict (in)equality', function( assert ) {
153117
assert.expect( 169 );
154118
var gcDefs = [

tests/src/dataValues.DataValue.tests.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,28 +131,6 @@ define( [
131131
}
132132
},
133133

134-
/**
135-
* Tests the getSortKey method.
136-
*
137-
* @since 0.1
138-
*
139-
* @param {QUnit.assert} assert
140-
*/
141-
testGetSortKey: function( assert ) {
142-
var instances = this.getInstances(),
143-
i,
144-
keyType;
145-
146-
for ( i in instances ) {
147-
keyType = typeof( instances[i].getSortKey() );
148-
149-
assert.ok(
150-
keyType === 'string' || keyType === 'number',
151-
'return value is a string or number'
152-
);
153-
}
154-
},
155-
156134
/**
157135
* Tests whether the data value's constructor has a newFromJSON function.
158136
*

0 commit comments

Comments
 (0)