Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into pushToExternalConfig
Browse files Browse the repository at this point in the history
* upstream/main:
  Use OpenRewrite UseStringReplace (#10299)
  Add ReplaceStringBuilderWithString (#10302)
  Apply ShortenFullyQualifiedTypeReferences (#10301)
  Apply StaticMethodNotFinal (#10300)
  Apply exit early pattern (#10297)
  Avoid GH_TOKEN_UPDATE_GRADLE_WRAPPER at refresh-csl-subtrees
  Update snapcraft.yaml
  Fix exception when opening preferences (#10294)
  gnome-42-2204
  use gnome 4.2
  Use gnome
  Update base 22
  • Loading branch information
Siedlerchr committed Sep 3, 2023
2 parents 3de2baf + 07f54ed commit 11bbbd0
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 89 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/refresh-csl-subtrees.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,22 @@ jobs:
publish:
name: Refresh Citation Style Language Files
runs-on: ubuntu-latest
if: github.repository == 'JabRef/jabref'
permissions:
contents: write # for peter-evans/create-pull-request to create branch
pull-requests: write # for peter-evans/create-pull-request to create a PR
if: (github.repository == 'JabRef/jabref' || github.repository == 'koppor/jabref')
steps:
- name: Checkout source
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
persist-credentials: true
ref: main
fetch-depth: 0
- name: Initialize git
run: |
git checkout main
git config --local core.editor /usr/bin/cat
git config user.name "github actions"
git config user.email "jabrefmail+webfeedback@gmail.com"
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Add csl-styles remote
run: git remote add -f csl-styles https://github.com/citation-style-language/styles.git
- name: Update csl-styles
Expand All @@ -48,8 +51,8 @@ jobs:
git commit -m"Refresh example styles" || true
- uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GH_TOKEN_UPDATE_GRADLE_WRAPPER }}
token: ${{ secrets.GITHUB_TOKEN }}
branch: refresh-csl
commit-message: Update CSL styles
title: "[Bot] Update CSL styles"
commit-message: Update CSL styles
labels: dependencies
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,10 @@ tasks.register("generateBstGrammarSource", JavaExec) {
}

tasks.register("generateSearchGrammarSource", JavaExec) {
main = "org.antlr.v4.Tool"
classpath = configurations.antlr4
group = 'JabRef'
description = "Generates java files for Search.g antlr4."
classpath = configurations.antlr4
main = "org.antlr.v4.Tool"

inputs.dir("src/main/antlr4/org/jabref/search/")
outputs.dir("src-gen/main/java/org/jabref/search/")
Expand Down
7 changes: 5 additions & 2 deletions rewrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ recipeList:
# We voted against it
# - org.openrewrite.staticanalysis.ExplicitInitialization

- org.openrewrite.java.ShortenFullyQualifiedTypeReferences

- org.openrewrite.staticanalysis.AtomicPrimitiveEqualsUsesGet
- org.openrewrite.staticanalysis.BigDecimalRoundingConstantsToEnums
- org.openrewrite.staticanalysis.BooleanChecksNotInverted
Expand Down Expand Up @@ -156,13 +158,14 @@ recipeList:
# - org.openrewrite.staticanalysis.RenameLocalVariablesToCamelCase
- org.openrewrite.staticanalysis.RenameMethodsNamedHashcodeEqualOrTostring
- org.openrewrite.staticanalysis.ReplaceRedundantFormatWithPrintf
- org.openrewrite.staticanalysis.ReplaceStringBuilderWithString
# - org.openrewrite.staticanalysis.ShortenFullyQualifiedTypeReferences
# - org.openrewrite.staticanalysis.SimplifyConsecutiveAssignments
# - org.openrewrite.staticanalysis.SimplifyCompoundStatement
- org.openrewrite.staticanalysis.SimplifyBooleanExpression
- org.openrewrite.staticanalysis.SimplifyBooleanReturn
- org.openrewrite.staticanalysis.SimplifyDurationCreationUnits
# - org.openrewrite.staticanalysis.StaticMethodNotFinal
- org.openrewrite.staticanalysis.StaticMethodNotFinal
- org.openrewrite.staticanalysis.StringLiteralEquality
- org.openrewrite.staticanalysis.TypecastParenPad
- org.openrewrite.staticanalysis.UnwrapRepeatableAnnotations
Expand All @@ -172,7 +175,7 @@ recipeList:
# - org.openrewrite.staticanalysis.UseListSort
- org.openrewrite.staticanalysis.UseObjectNotifyAll
- org.openrewrite.staticanalysis.UseStandardCharset
# - org.openrewrite.staticanalysis.UseStringReplace
- org.openrewrite.staticanalysis.UseStringReplace
- org.openrewrite.staticanalysis.UseSystemLineSeparator
- org.openrewrite.staticanalysis.WhileInsteadOfFor
# - org.openrewrite.staticanalysis.WriteOctalValuesAsDecimal
13 changes: 7 additions & 6 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ description: |
`snap connect jabref:removable-media`
grade: stable
confinement: strict
base: core20
base: core22
compression: lzo
architectures:
- build-on: amd64
- build-on: [amd64, arm64]
build-for: [amd64]

plugs:
home:
Expand Down Expand Up @@ -45,10 +46,10 @@ layout:
apps:
jabref:
command: bin/JabRef
extensions: [gnome-3-38]
extensions: [gnome]
browser-proxy:
command: lib/jabrefHost.py
extensions: [gnome-3-38]
extensions: [gnome]

environment:
_JAVA_OPTIONS: "-Duser.home=$SNAP_USER_DATA"
Expand Down Expand Up @@ -80,10 +81,10 @@ parts:
- jabref-launcher
plugin: nil
build-snaps:
- gnome-3-38-2004
- gnome-42-2204
override-prime: |
set -eux
for snap in "gnome-3-38-2004"; do # List all content-snaps you're using here
for snap in "gnome-42-2204"; do # List all content-snaps you're using here
cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" "$SNAPCRAFT_PRIME/usr/{}" \;
done
for CRUFT in bug lintian man; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected void bindToEntry(BibEntry entry) {
// Iterate through pages (within file) with search hits
for (SearchResult searchResult : resultsForPath.getValue()) {
for (String resultTextHtml : searchResult.getContentResultStringsHtml()) {
content.getChildren().addAll(TooltipTextUtil.createTextsFromHtml(resultTextHtml.replaceAll("</b> <b>", " ")));
content.getChildren().addAll(TooltipTextUtil.createTextsFromHtml(resultTextHtml.replace("</b> <b>", " ")));
content.getChildren().addAll(new Text(System.lineSeparator()), lineSeparator(0.8), createPageLink(searchResult.getPageNumber()));
}
if (!searchResult.getAnnotationsResultStringsHtml().isEmpty()) {
Expand All @@ -108,7 +108,7 @@ protected void bindToEntry(BibEntry entry) {
content.getChildren().add(annotationsText);
}
for (String resultTextHtml : searchResult.getAnnotationsResultStringsHtml()) {
content.getChildren().addAll(TooltipTextUtil.createTextsFromHtml(resultTextHtml.replaceAll("</b> <b>", " ")));
content.getChildren().addAll(TooltipTextUtil.createTextsFromHtml(resultTextHtml.replace("</b> <b>", " ")));
content.getChildren().addAll(new Text(System.lineSeparator()), lineSeparator(0.8), createPageLink(searchResult.getPageNumber()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLSocketFactory;

import javafx.beans.Observable;
Expand Down Expand Up @@ -500,7 +501,7 @@ public boolean checkSSLHandshake(URLDownload urlDownload) {
try {
urlDownload.canBeReached();
} catch (kong.unirest.UnirestException ex) {
if (ex.getCause() instanceof javax.net.ssl.SSLHandshakeException) {
if (ex.getCause() instanceof SSLHandshakeException) {
if (dialogService.showConfirmationDialogAndWait(Localization.lang("Download file"),
Localization.lang("Unable to find valid certification path to requested target(%0), download anyway?",
urlDownload.getSource().toString()))) {
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/org/jabref/gui/journals/AbbreviateAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ private String abbreviate(BibDatabaseContext databaseContext, List<BibEntry> ent
}
}).count();

if (count > 0) {
ce.end();
frame.getUndoManager().addEdit(ce);
frame.getCurrentLibraryTab().markBaseChanged();
return Localization.lang("Abbreviated %0 journal names.", String.valueOf(count));
if (count == 0) {
return Localization.lang("No journal names could be abbreviated.");
}
return Localization.lang("No journal names could be abbreviated.");

ce.end();
frame.getUndoManager().addEdit(ce);
frame.getCurrentLibraryTab().markBaseChanged();
return Localization.lang("Abbreviated %0 journal names.", String.valueOf(count));
}

private String unabbreviate(BibDatabaseContext databaseContext, List<BibEntry> entries) {
Expand All @@ -126,12 +127,13 @@ private String unabbreviate(BibDatabaseContext databaseContext, List<BibEntry> e
int count = entries.stream().mapToInt(entry ->
(int) FieldFactory.getJournalNameFields().stream().filter(journalField ->
undoableAbbreviator.unabbreviate(databaseContext.getDatabase(), entry, journalField, ce)).count()).sum();
if (count > 0) {
ce.end();
frame.getUndoManager().addEdit(ce);
frame.getCurrentLibraryTab().markBaseChanged();
return Localization.lang("Unabbreviated %0 journal names.", String.valueOf(count));
if (count == 0) {
return Localization.lang("No journal names could be unabbreviated.");
}
return Localization.lang("No journal names could be unabbreviated.");

ce.end();
frame.getUndoManager().addEdit(ce);
frame.getCurrentLibraryTab().markBaseChanged();
return Localization.lang("Unabbreviated %0 journal names.", String.valueOf(count));
}
}
17 changes: 9 additions & 8 deletions src/main/java/org/jabref/gui/openoffice/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.jabref.gui.openoffice;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
Expand Down Expand Up @@ -107,7 +108,7 @@ private static void insertBasicFactories(XSet xSet, XImplementationLoader xImpLo
* @see #bootstrap(String[])
* @since LibreOffice 5.1
*/
public static final String[] getDefaultOptions() {
public static String[] getDefaultOptions() {
return new String[] {"--nologo", "--nodefault", "--norestore", "--nolockcheck"};
}

Expand Down Expand Up @@ -176,7 +177,7 @@ public static XMultiServiceFactory createSimpleServiceManager() throws Exception
* <code>cppuhelper/defaultBootstrap_InitialComponentContext()</code>.
* @throws Exception if things go awry.
*/
public static final XComponentContext defaultBootstrap_InitialComponentContext() throws Exception {
public static XComponentContext defaultBootstrap_InitialComponentContext() throws Exception {
return defaultBootstrap_InitialComponentContext((String) null, (Map<String, String>) null);
}

Expand All @@ -188,7 +189,7 @@ public static final XComponentContext defaultBootstrap_InitialComponentContext()
* @return a freshly bootstrapped component context.
* @throws Exception if things go awry.
*/
public static final XComponentContext defaultBootstrap_InitialComponentContext(String ini_file, Hashtable<String, String> bootstrap_parameters) throws Exception {
public static XComponentContext defaultBootstrap_InitialComponentContext(String ini_file, Hashtable<String, String> bootstrap_parameters) throws Exception {
return defaultBootstrap_InitialComponentContext(ini_file, (Map<String, String>) bootstrap_parameters);
}

Expand All @@ -203,7 +204,7 @@ public static final XComponentContext defaultBootstrap_InitialComponentContext(S
* @return a freshly bootstrapped component context.
* @throws Exception if things go awry.
*/
public static final XComponentContext defaultBootstrap_InitialComponentContext(String ini_file, Map<String, String> bootstrap_parameters) throws Exception {
public static XComponentContext defaultBootstrap_InitialComponentContext(String ini_file, Map<String, String> bootstrap_parameters) throws Exception {
// jni convenience: easier to iterate over array than calling Hashtable
String pairs[] = null;
if (null != bootstrap_parameters) {
Expand Down Expand Up @@ -253,7 +254,7 @@ public static final XComponentContext defaultBootstrap_InitialComponentContext(S
* @throws BootstrapException if things go awry.
* @since UDK 3.1.0
*/
public static final XComponentContext bootstrap(Path ooPath) throws BootstrapException {
public static XComponentContext bootstrap(Path ooPath) throws BootstrapException {
String[] defaultArgArray = getDefaultOptions();
return bootstrap(defaultArgArray, ooPath);
}
Expand All @@ -267,7 +268,7 @@ public static final XComponentContext bootstrap(Path ooPath) throws BootstrapExc
* @see #getDefaultOptions()
* @since LibreOffice 5.1
*/
public static final XComponentContext bootstrap(String[] argArray, Path path) throws BootstrapException {
public static XComponentContext bootstrap(String[] argArray, Path path) throws BootstrapException {

XComponentContext xContext = null;

Expand Down Expand Up @@ -326,7 +327,7 @@ public static final XComponentContext bootstrap(String[] argArray, Path path) th
throw e;
} catch (java.lang.RuntimeException e) {
throw e;
} catch (java.lang.Exception e) {
} catch (Exception e) {
throw new BootstrapException(e);
}

Expand All @@ -349,7 +350,7 @@ public void run() {
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace(System.err);
} catch (java.io.IOException e) {
} catch (IOException e) {
e.printStackTrace(System.err);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/gui/openoffice/OOBibBaseConnect.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private XDesktop simpleBootstrap(Path loPath)
BootstrapException {

// Get the office component context:
XComponentContext context = org.jabref.gui.openoffice.Bootstrap.bootstrap(loPath);
XComponentContext context = Bootstrap.bootstrap(loPath);
XMultiComponentFactory sem = context.getServiceManager();

// Create the desktop, which is the root frame of the
Expand All @@ -85,7 +85,7 @@ public static void closeOfficeConnection() {
try {
// get the bridge factory from the local service manager
XBridgeFactory bridgeFactory = queryInterface(XBridgeFactory.class,
org.jabref.gui.openoffice.Bootstrap.createSimpleServiceManager()
Bootstrap.createSimpleServiceManager()
.createInstance("com.sun.star.bridge.BridgeFactory"));

if (bridgeFactory != null) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jabref/gui/search/GlobalSearchBar.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.search;

import java.lang.reflect.Field;
import java.time.Duration;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -200,7 +201,7 @@ public GlobalSearchBar(JabRefFrame frame, StateManager stateManager, Preferences
this.setSpacing(4.0);
this.setAlignment(Pos.CENTER_LEFT);

Timer searchTask = FxTimer.create(java.time.Duration.ofMillis(SEARCH_DELAY), this::performSearch);
Timer searchTask = FxTimer.create(Duration.ofMillis(SEARCH_DELAY), this::performSearch);
BindingsHelper.bindBidirectional(
stateManager.activeSearchQueryProperty(),
searchField.textProperty(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ private static String firstAuthorForenameInitials(AuthorList authorList) {
*/
private static String firstAuthorVonAndLast(AuthorList authorList) {
return authorList.isEmpty() ? "" :
authorList.getAuthor(0).getLastOnly().replaceAll(" ", "");
authorList.getAuthor(0).getLastOnly().replace(" ", "");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public AuthorList parse(String listOfNames) {
// Usually the getAsLastFirstNamesWithAnd method would separate them if pre- and lastname are separated with "and"
// If not, we check if spaces separate pre- and lastname
if (spaceInAllParts) {
listOfNames = listOfNames.replaceAll(",", " and");
listOfNames = listOfNames.replace(",", " and");
} else {
// Looking for name affixes to avoid
// arrayNameList needs to reduce by the count off avoiding terms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public String getIdentifierName() {
*/
protected class ArXiv implements FulltextFetcher, PagedSearchBasedFetcher, IdBasedFetcher, IdFetcher<ArXivIdentifier> {

private static final Logger LOGGER = LoggerFactory.getLogger(org.jabref.logic.importer.fetcher.ArXivFetcher.ArXiv.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ArXivFetcher.ArXiv.class);

private static final String API_URL = "https://export.arxiv.org/api/query";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ private String makeServerRequest(String queryByTitle) throws FetcherException {
String response = urlDownload.asString();

// Conversion of < and >
response = response.replaceAll("&gt;", ">");
response = response.replaceAll("&lt;", "<");
response = response.replace("&gt;", ">");
response = response.replace("&lt;", "<");
return response;
} catch (IOException e) {
throw new FetcherException("Problem downloading", e);
Expand All @@ -117,7 +117,7 @@ private String makeServerRequest(String queryByTitle) throws FetcherException {
*/
private String constructQuery(String queryWithTitle) {
// The encoding does not work for / so we convert them by our own
queryWithTitle = queryWithTitle.replaceAll("/", " ");
queryWithTitle = queryWithTitle.replace("/", " ");
URIBuilder builder = new URIBuilder();
builder.setScheme("http");
builder.setHost(MDL_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private void addAbstract(Map<Field, String> hm, String lab, String value) {
if (value.contains("Copyright")) {
int copyrightIndex = value.lastIndexOf("Copyright");
// remove the copyright from the field since the name of the field is copyright
String copyrightInfo = value.substring(copyrightIndex).replaceAll("Copyright ", "");
String copyrightInfo = value.substring(copyrightIndex).replace("Copyright ", "");
hm.put(new UnknownField("copyright"), copyrightInfo);
abstractValue = value.substring(0, copyrightIndex);
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/logic/layout/StringInt.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package org.jabref.logic.layout;

import java.io.Serializable;

/**
* String and integer value.
*/
public class StringInt implements java.io.Serializable {
public class StringInt implements Serializable {

/**
* Description of the Field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ public class AuthorAndToSemicolonReplacer implements LayoutFormatter {

@Override
public String format(String fieldText) {
return fieldText.replaceAll(" and ", "; ");
return fieldText.replace(" and ", "; ");
}
}
Loading

0 comments on commit 11bbbd0

Please sign in to comment.