Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
import org.jabref.model.entry.KeywordList;
import org.jabref.model.entry.field.Field;

import org.tinylog.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class KeywordsEditorViewModel extends AbstractEditorViewModel {

private static final Logger LOGGER = LoggerFactory.getLogger(KeywordsEditorViewModel.class);

private final ListProperty<Keyword> keywordListProperty;
private final Character keywordSeparator;
private final SuggestionProvider<?> suggestionProvider;
Expand Down Expand Up @@ -62,7 +65,7 @@ public StringConverter<Keyword> getStringConverter() {
@Override
public String toString(Keyword keyword) {
if (keyword == null) {
Logger.debug("Keyword is null");
LOGGER.debug("Keyword is null");
return "";
}
return keyword.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import org.jabref.logic.importer.plaincitation.PlainCitationParserChoice;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.preferences.FetcherApiKey;
import org.jabref.model.strings.StringUtil;

import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;
import org.apache.logging.log4j.util.Strings;

public class WebSearchTab extends AbstractPreferenceTabView<WebSearchTabViewModel> implements PreferencesTab {

Expand Down Expand Up @@ -99,7 +99,7 @@ public void initialize() {
citationsRelationStoreTTL
.textProperty()
.addListener((_, _, newValue) -> {
if (Strings.isBlank(newValue)) {
if (StringUtil.isBlank(newValue)) {
return;
}
if (!newValue.matches("\\d*")) {
Expand Down
10 changes: 4 additions & 6 deletions jablib/src/main/java/org/jabref/logic/os/OS.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.nio.file.Path;
import java.util.Locale;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.jabref.model.strings.StringUtil;

Expand All @@ -17,6 +15,7 @@
import com.github.javakeyring.PasswordAccessException;
import mslinks.ShellLink;
import mslinks.ShellLinkException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
Expand Down Expand Up @@ -87,11 +86,10 @@ public static String detectProgramPath(String programName, String directoryName)
try {
ShellLink link = new ShellLink(texworksLinkPath);
return link.resolveTarget();
} catch (IOException
| ShellLinkException e) {
} catch (IOException | ShellLinkException e) {
// Static logger instance cannot be used. See the class comment.
Logger logger = Logger.getLogger(OS.class.getName());
logger.log(Level.WARNING, "Had an error while reading .lnk file for TeXworks", e);
Logger logger = LoggerFactory.getLogger(OS.class);
logger.warn("Error while reading .lnk file for TeXworks", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.net.URI;
import java.nio.file.Paths;
import java.util.List;

import org.jabref.architecture.AllowedToUseApacheCommonsLang3;
import org.jabref.architecture.AllowedToUseAwt;
Expand Down Expand Up @@ -89,8 +90,6 @@ public void useStreamsOfResources(JavaClasses classes) {
.check(classes);
}

// TODO: no org.jabref.gui package may reside in org.jabref.logic

@ArchTest
public void doNotUseLogicInModel(JavaClasses classes) {
ArchRuleDefinition.noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_MODEL)
Expand All @@ -99,6 +98,13 @@ public void doNotUseLogicInModel(JavaClasses classes) {
.check(classes);
}

@ArchTest
public void doNotUseGuiInLogic(JavaClasses classes) {
ArchRuleDefinition.noClasses().that().resideInAPackage(PACKAGE_ORG_JABREF_LOGIC)
.should().dependOnClassesThat().resideInAPackage(PACKAGE_ORG_JABREF_GUI)
.check(classes);
}

@ArchTest
public void restrictUsagesInModel(JavaClasses classes) {
// Until we switch to Lucene, we need to access Globals.stateManager().getActiveDatabase() from the search classes,
Expand All @@ -120,6 +126,27 @@ public void restrictUsagesInLogic(JavaClasses classes) {
.check(classes);
}

@ArchTest
public void restrictToSlf4jLogger(JavaClasses classes) {
List<String> restrictedLoggingPackages = List.of(
"java.util.logging..", // Java's built-in logging
"org.apache.log4j..", // Log4j 1.x
"org.apache.logging.log4j..", // Log4j 2.x
"org.slf4j.impl..", // Concrete SLF4J bindings
"ch.qos.logback..", // Logback
"org.apache.commons.logging..", // Apache Commons logging
"org.tinylog..", // Tinylog
"org.mariadb.jdbc.internal.logging.." // Mariadb logging
);

ArchRuleDefinition.noClasses()
.that().resideOutsideOfPackages("org.jabref.gui.errorconsole", "org.jabref.gui.logging", "org.jabref")
.should().accessClassesThat()
.resideInAnyPackage(restrictedLoggingPackages.toArray(String[]::new))
.because("slf4j should be used for logging")
.check(classes);
}

@ArchTest
public void restrictStandardStreams(JavaClasses classes) {
ArchRuleDefinition.noClasses().that().resideOutsideOfPackages(PACKAGE_ORG_JABREF_CLI)
Expand Down