Skip to content

Commit cbd0406

Browse files
committed
Analysis: Wrap at 140 columns (#34494)
Applies our standard column width to all analysis plugins.
1 parent e3ad9f3 commit cbd0406

File tree

7 files changed

+36
-24
lines changed

7 files changed

+36
-24
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,12 +709,6 @@
709709
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]versioning[/\\]SimpleVersioningIT.java" checks="LineLength" />
710710
<suppress files="modules[/\\]lang-painless[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]painless[/\\]ContextExampleTests.java" checks="LineLength" />
711711
<suppress files="modules[/\\]reindex[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]reindex[/\\]TransportUpdateByQueryAction.java" checks="LineLength" />
712-
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IcuCollationTokenFilterFactory.java" checks="LineLength" />
713-
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IcuFoldingTokenFilterFactory.java" checks="LineLength" />
714-
<suppress files="plugins[/\\]analysis-icu[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]IndexableBinaryStringTools.java" checks="LineLength" />
715-
<suppress files="plugins[/\\]analysis-kuromoji[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]JapaneseStopTokenFilterFactory.java" checks="LineLength" />
716-
<suppress files="plugins[/\\]analysis-kuromoji[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]KuromojiAnalysisTests.java" checks="LineLength" />
717-
<suppress files="plugins[/\\]analysis-phonetic[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]index[/\\]analysis[/\\]PhoneticTokenFilterFactory.java" checks="LineLength" />
718712
<suppress files="plugins[/\\]discovery-ec2[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]discovery[/\\]ec2[/\\]AbstractAwsTestCase.java" checks="LineLength" />
719713
<suppress files="plugins[/\\]discovery-ec2[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]discovery[/\\]ec2[/\\]AmazonEC2Mock.java" checks="LineLength" />
720714
<suppress files="plugins[/\\]discovery-gce[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]discovery[/\\]gce[/\\]GceNetworkTests.java" checks="LineLength" />

plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@
3636

3737
/**
3838
* An ICU based collation token filter. There are two ways to configure collation:
39-
* <p>The first is simply specifying the locale (defaults to the default locale). The {@code language}
40-
* parameter is the lowercase two-letter ISO-639 code. An additional {@code country} and {@code variant}
39+
* <p>The first is simply specifying the locale (defaults to the default
40+
* locale). The {@code language} parameter is the lowercase two-letter
41+
* ISO-639 code. An additional {@code country} and {@code variant}
4142
* can be provided.
42-
* <p>The second option is to specify collation rules as defined in the <a href="http://www.icu-project.org/userguide/Collate_Customization.html">
43-
* Collation customization</a> chapter in icu docs. The {@code rules} parameter can either embed the rules definition
44-
* in the settings or refer to an external location (preferable located under the {@code config} location, relative to it).
43+
* <p>The second option is to specify collation rules as defined in the
44+
* <a href="http://www.icu-project.org/userguide/Collate_Customization.html">
45+
* Collation customization</a> chapter in icu docs. The {@code rules}
46+
* parameter can either embed the rules definition
47+
* in the settings or refer to an external location (preferable located under
48+
* the {@code config} location, relative to it).
4549
*/
4650
public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory {
4751

@@ -132,7 +136,8 @@ public IcuCollationTokenFilterFactory(IndexSettings indexSettings, Environment e
132136
}
133137
}
134138

135-
Boolean caseLevel = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "caseLevel", null, deprecationLogger);
139+
Boolean caseLevel = settings.getAsBooleanLenientForPreEs6Indices(
140+
indexSettings.getIndexVersionCreated(), "caseLevel", null, deprecationLogger);
136141
if (caseLevel != null) {
137142
rbc.setCaseLevel(caseLevel);
138143
}
@@ -148,7 +153,8 @@ public IcuCollationTokenFilterFactory(IndexSettings indexSettings, Environment e
148153
}
149154
}
150155

151-
Boolean numeric = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "numeric", null, deprecationLogger);
156+
Boolean numeric = settings.getAsBooleanLenientForPreEs6Indices(
157+
indexSettings.getIndexVersionCreated(), "numeric", null, deprecationLogger);
152158
if (numeric != null) {
153159
rbc.setNumericCollation(numeric);
154160
}

plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
* Uses the {@link org.apache.lucene.analysis.icu.ICUFoldingFilter}.
3333
* Applies foldings from UTR#30 Character Foldings.
3434
* <p>
35-
* Can be filtered to handle certain characters in a specified way (see http://icu-project.org/apiref/icu4j/com/ibm/icu/text/UnicodeSet.html)
35+
* Can be filtered to handle certain characters in a specified way
36+
* (see http://icu-project.org/apiref/icu4j/com/ibm/icu/text/UnicodeSet.html)
3637
* E.g national chars that should be retained (filter : "[^åäöÅÄÖ]").
3738
*
38-
* <p>The {@code unicodeSetFilter} attribute can be used to provide the UniCodeSet for filtering.
39+
* <p>The {@code unicodeSetFilter} attribute can be used to provide the
40+
* UniCodeSet for filtering.
3941
*
4042
* @author kimchy (shay.banon)
4143
*/

plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IndexableBinaryStringTools.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ public static void encode(byte[] inputArray, int inputOffset,
133133
codingCase = CODING_CASES[caseNum];
134134

135135
if (inputByteNum + 1 < inputLength) { // codingCase.numBytes must be 3
136-
outputArray[outputCharNum++] = (char) ((((inputArray[inputByteNum] & 0xFF) << codingCase.initialShift) + ((inputArray[inputByteNum + 1] & 0xFF) << codingCase.middleShift)) & (short) 0x7FFF);
136+
outputArray[outputCharNum++] = (char) (
137+
( ((inputArray[inputByteNum] & 0xFF) << codingCase.initialShift)
138+
+ ((inputArray[inputByteNum + 1] & 0xFF) << codingCase.middleShift)
139+
) & (short) 0x7FFF);
137140
// Add trailing char containing the number of full bytes in final char
138141
outputArray[outputCharNum++] = (char) 1;
139142
} else if (inputByteNum < inputLength) {

plugins/analysis-kuromoji/src/main/java/org/elasticsearch/index/analysis/JapaneseStopTokenFilterFactory.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ public class JapaneseStopTokenFilterFactory extends AbstractTokenFilterFactory{
4545

4646
public JapaneseStopTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
4747
super(indexSettings, name, settings);
48-
this.ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case", false, deprecationLogger);
49-
this.removeTrailing = settings
50-
.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "remove_trailing", true, deprecationLogger);
51-
this.stopWords = Analysis.parseWords(env, settings, "stopwords", JapaneseAnalyzer.getDefaultStopSet(), NAMED_STOP_WORDS, ignoreCase);
48+
this.ignoreCase = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "ignore_case",
49+
false, deprecationLogger);
50+
this.removeTrailing = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "remove_trailing",
51+
true, deprecationLogger);
52+
this.stopWords = Analysis.parseWords(env, settings, "stopwords", JapaneseAnalyzer.getDefaultStopSet(),
53+
NAMED_STOP_WORDS, ignoreCase);
5254
}
5355

5456
@Override

plugins/analysis-kuromoji/src/test/java/org/elasticsearch/index/analysis/KuromojiAnalysisTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ public void testKatakanaStemFilter() throws IOException {
139139

140140
// パーティー should be stemmed by default
141141
// (min len) コピー should not be stemmed
142-
String[] expected_tokens_katakana = new String[]{"明後日", "パーティ", "に", "行く", "予定", "が", "ある", "図書館", "で", "資料", "を", "コピー", "し", "まし", "た"};
142+
String[] expected_tokens_katakana = new String[] {
143+
"明後日", "パーティ", "に", "行く", "予定", "が", "ある", "図書館", "で", "資料", "を", "コピー", "し", "まし", "た"};
143144
assertSimpleTSOutput(tokenFilter.create(tokenizer), expected_tokens_katakana);
144145

145146
tokenFilter = analysis.tokenFilter.get("kuromoji_ks");
@@ -149,7 +150,8 @@ public void testKatakanaStemFilter() throws IOException {
149150

150151
// パーティー should not be stemmed since min len == 6
151152
// コピー should not be stemmed
152-
expected_tokens_katakana = new String[]{"明後日", "パーティー", "に", "行く", "予定", "が", "ある", "図書館", "で", "資料", "を", "コピー", "し", "まし", "た"};
153+
expected_tokens_katakana = new String[] {
154+
"明後日", "パーティー", "に", "行く", "予定", "が", "ある", "図書館", "で", "資料", "を", "コピー", "し", "まし", "た"};
153155
assertSimpleTSOutput(tokenFilter.create(tokenizer), expected_tokens_katakana);
154156
}
155157

plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public PhoneticTokenFilterFactory(IndexSettings indexSettings, Environment envir
6161
this.nametype = null;
6262
this.ruletype = null;
6363
this.maxcodelength = 0;
64-
this.replace = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(), "replace", true, deprecationLogger);
64+
this.replace = settings.getAsBooleanLenientForPreEs6Indices(indexSettings.getIndexVersionCreated(),
65+
"replace", true, deprecationLogger);
6566
this.isDaitchMokotoff = false;
6667
// weird, encoder is null at last step in SimplePhoneticAnalysisTests, so we set it to metaphone as default
6768
String encodername = settings.get("encoder", "metaphone");
@@ -82,7 +83,9 @@ public PhoneticTokenFilterFactory(IndexSettings indexSettings, Environment envir
8283
} else if ("double_metaphone".equalsIgnoreCase(encodername) || "doubleMetaphone".equalsIgnoreCase(encodername)) {
8384
this.encoder = null;
8485
this.maxcodelength = settings.getAsInt("max_code_len", 4);
85-
} else if ("bm".equalsIgnoreCase(encodername) || "beider_morse".equalsIgnoreCase(encodername) || "beidermorse".equalsIgnoreCase(encodername)) {
86+
} else if ("bm".equalsIgnoreCase(encodername)
87+
|| "beider_morse".equalsIgnoreCase(encodername)
88+
|| "beidermorse".equalsIgnoreCase(encodername)) {
8689
this.encoder = null;
8790
this.languageset = settings.getAsList("languageset");
8891
String ruleType = settings.get("rule_type", "approx");

0 commit comments

Comments
 (0)