From: Niki Roo Date: Sat, 8 Jul 2017 04:25:53 +0000 (+0200) Subject: Add more warnings source to 1.6) and fix warnings X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=commitdiff_plain;h=d5260eeb873fcf2ef9855dedcd9e2a3a3a990582 Add more warnings source to 1.6) and fix warnings --- diff --git a/src/be/nikiroo/jvcard/Contact.java b/src/be/nikiroo/jvcard/Contact.java index 93bd809..6d362f9 100644 --- a/src/be/nikiroo/jvcard/Contact.java +++ b/src/be/nikiroo/jvcard/Contact.java @@ -131,7 +131,7 @@ public class Contact extends BaseClass { * @return the {@link String} representation */ public String toString(String format, String separator) { - return toString(format, separator, null, -1, true, false); + return toString(format, separator, null, -1, true); } /** @@ -173,14 +173,13 @@ public class Contact extends BaseClass { * the {@link String} to use for left and right padding * @param width * a fixed width or -1 for "as long as needed" - * * @param unicode - * allow Uniode or only ASCII characters + * allow Unicode or only ASCII characters * * @return the {@link String} representation */ public String toString(String format, String separator, String padding, - int width, boolean unicode, boolean removeAccents) { + int width, boolean unicode) { StringBuilder builder = new StringBuilder(); for (String str : toStringArray(format, separator, padding, width, @@ -305,7 +304,7 @@ public class Contact extends BaseClass { * a fixed width or -1 for "as long as needed" * @param unicode * allow Uniode or only ASCII characters - * + * * @return the {@link String} representation */ public String[] toStringArray(String format, int width, boolean unicode) { diff --git a/src/be/nikiroo/jvcard/launcher/CardResult.java b/src/be/nikiroo/jvcard/launcher/CardResult.java index 68a5ae7..4a0afd6 100644 --- a/src/be/nikiroo/jvcard/launcher/CardResult.java +++ b/src/be/nikiroo/jvcard/launcher/CardResult.java @@ -9,7 +9,7 @@ import be.nikiroo.jvcard.Card; * about it. * * @author niki - * + * */ public class CardResult { /** @@ -17,7 +17,7 @@ public class CardResult { * synchronisation is not able to process fully automatically. * * @author niki - * + * */ public interface MergeCallback { /** @@ -59,6 +59,7 @@ public class CardResult { */ public CardResult(Card card, boolean remote, boolean synced, boolean changed) { this.card = card; + this.remote = remote; this.synced = synced; this.changed = changed; } diff --git a/src/be/nikiroo/jvcard/launcher/Main.java b/src/be/nikiroo/jvcard/launcher/Main.java index d893e10..69ed7e9 100644 --- a/src/be/nikiroo/jvcard/launcher/Main.java +++ b/src/be/nikiroo/jvcard/launcher/Main.java @@ -301,11 +301,10 @@ public class Main { ERR(StringId.CLI_ERR, StringId.CLI_ERR_NO_REMOTING, ERR_INTERNAL); return; - } else { - e.printStackTrace(); - ERR(StringId.CLI_ERR, StringId.CLI_ERR, ERR_INTERNAL); - return; } + e.printStackTrace(); + ERR(StringId.CLI_ERR, StringId.CLI_ERR, ERR_INTERNAL); + return; } break; } @@ -415,11 +414,10 @@ public class Main { if (!e.isCompiledIn()) { ERR(StringId.CLI_ERR, StringId.CLI_ERR_NO_TUI, ERR_INTERNAL); return; - } else { - e.printStackTrace(); - ERR(StringId.CLI_ERR, StringId.CLI_ERR, ERR_INTERNAL); - return; } + e.printStackTrace(); + ERR(StringId.CLI_ERR, StringId.CLI_ERR, ERR_INTERNAL); + return; } break; } diff --git a/src/be/nikiroo/jvcard/parsers/AbookParser.java b/src/be/nikiroo/jvcard/parsers/AbookParser.java index b8e6e58..fc4df36 100644 --- a/src/be/nikiroo/jvcard/parsers/AbookParser.java +++ b/src/be/nikiroo/jvcard/parsers/AbookParser.java @@ -58,11 +58,12 @@ public class AbookParser { * * @param startingBKey * the starting BKey number (all the other will follow) or -1 for - * no BKey + * no BKey (it is actually not used in this mode) * * @return the {@link String} representation */ - public static List toStrings(Contact contact, int startingBKey) { + public static List toStrings(Contact contact, + @SuppressWarnings("unused") int startingBKey) { // BKey is not used in pine mode StringBuilder builder = new StringBuilder(); diff --git a/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java b/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java index 5a07903..d6e607a 100644 --- a/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java +++ b/src/be/nikiroo/jvcard/parsers/Vcard21Parser.java @@ -161,15 +161,15 @@ public class Vcard21Parser { * @param contact * the {@link Contact} to write * @param startingBKey - * the starting BKey number (all the other will follow) or -1 for - * no BKey + * the starting BKey number (all the others will follow) or -1 + * for no BKey * * @throws IOException * in case of IO error */ public static void write(Appendable writer, Contact contact, int startingBKey) throws IOException { - + // TODO: bkey handling? writer.append("BEGIN:VCARD\r\n"); writer.append("VERSION:2.1\r\n"); for (Data data : contact) { diff --git a/src/be/nikiroo/jvcard/remote/Server.java b/src/be/nikiroo/jvcard/remote/Server.java index 30c404c..6cba0c3 100644 --- a/src/be/nikiroo/jvcard/remote/Server.java +++ b/src/be/nikiroo/jvcard/remote/Server.java @@ -131,8 +131,9 @@ public class Server implements Runnable { try { ss.open(false); - while (processCmd(ss)) - ; + while (processCmd(ss)) { + // nothing to do: process the command + } } catch (IOException e) { e.printStackTrace(); @@ -237,8 +238,9 @@ public class Server implements Runnable { try { s.sendLine(StringUtils.fromTime(file.lastModified())); - while (processLockedCmd(s, name)) - ; + while (processLockedCmd(s, name)) { + // nothing to do: process the command + } } catch (InvalidParameterException e) { System.err .println("Unsupported command received from a client connection, closing it: " @@ -341,8 +343,9 @@ public class Server implements Runnable { } else { Card card = new Card(vcf, Format.VCard21); try { - while (processContactCmd(s, card)) - ; + while (processContactCmd(s, card)) { + // nothing to do: process the command + } card.save(); s.sendLine(StringUtils.fromTime(card.getLastModified())); } catch (InvalidParameterException e) { @@ -435,8 +438,9 @@ public class Server implements Runnable { throw new InvalidParameterException( "Cannot find contact to modify for UID: " + uid); } - while (processDataCmd(s, contact)) - ; + while (processDataCmd(s, contact)) { + // nothing to do: process the command + } break; } case DELETE_CONTACT: { diff --git a/src/be/nikiroo/jvcard/resources/StringId.java b/src/be/nikiroo/jvcard/resources/StringId.java index fbbb158..1b11e50 100644 --- a/src/be/nikiroo/jvcard/resources/StringId.java +++ b/src/be/nikiroo/jvcard/resources/StringId.java @@ -2,7 +2,6 @@ package be.nikiroo.jvcard.resources; import be.nikiroo.utils.resources.Meta; - /** * The enum representing textual information to be translated to the user as a * key. @@ -17,112 +16,112 @@ public enum StringId { DUMMY, // <-- TODO : remove NULL, // Special usage, no annotations so it is not visible in // .properties files - @Meta( info = "MUST BE 3 chars long", description = "Tab key") + @Meta(info = "MUST BE 3 chars long", description = "Tab key") KEY_TAB, // keys - @Meta( info = "MUST BE 3 chars long", description = "Enter key") + @Meta(info = "MUST BE 3 chars long", description = "Enter key") KEY_ENTER, // - @Meta( description = "Go back to previous screen") + @Meta(description = "Go back to previous screen") KEY_ACTION_BACK, // - @Meta( description = "Get help text") + @Meta(description = "Get help text") KEY_ACTION_HELP, // - @Meta( description = "View the selected card") + @Meta(description = "View the selected card") KEY_ACTION_VIEW_CARD, // - @Meta( description = "View the selected contact") + @Meta(description = "View the selected contact") KEY_ACTION_VIEW_CONTACT, // - @Meta( description = "Edit the contact") + @Meta(description = "Edit the contact") KEY_ACTION_EDIT_CONTACT, // - @Meta( description = "Edit the contact in RAW mode") + @Meta(description = "Edit the contact in RAW mode") KEY_ACTION_EDIT_CONTACT_RAW, // - @Meta( description = "Edit the RAW field") + @Meta(description = "Edit the RAW field") KEY_ACTION_EDIT_FIELD, // - @Meta( description = "Save the whole card") + @Meta(description = "Save the whole card") KEY_ACTION_SAVE_CARD, // - @Meta( description = "Delete the selected element") + @Meta(description = "Delete the selected element") KEY_ACTION_DELETE, // - @Meta( description = "Filter the displayed contacts") + @Meta(description = "Filter the displayed contacts") KEY_ACTION_SEARCH, // - @Meta( info = "we could use: ' ', ┃, │...", description = "Field separator") + @Meta(info = "we could use: ' ', ┃, │...", description = "Field separator") DEAULT_FIELD_SEPARATOR, // MainContentList - @Meta( description = "Invert the photo's colours") + @Meta(description = "Invert the photo's colours") KEY_ACTION_INVERT, // - @Meta( description = "Show the photo in 'fullscreen'") + @Meta(description = "Show the photo in 'fullscreen'") KEY_ACTION_FULLSCREEN, // - @Meta( description = "Switch between the available display formats") + @Meta(description = "Switch between the available display formats") KEY_ACTION_SWITCH_FORMAT, // multi-usage - @Meta( description = "Add a new contact/field") + @Meta(description = "Add a new contact/field") KEY_ACTION_ADD, // - @Meta( description = "New contact") + @Meta(description = "New contact") ASK_USER_CONTACT_NAME, // - @Meta( info = "%s = contact name", description = "Delete contact") + @Meta(info = "%s = contact name", description = "Delete contact") CONFIRM_USER_DELETE_CONTACT, // - @Meta( info = "%s = contact name", description = "cannot delete a contact") + @Meta(info = "%s = contact name", description = "cannot delete a contact") ERR_CANNOT_DELETE_CONTACT, // - @Meta( description = "The Help message header line") + @Meta(description = "The Help message header line") CLI_HELP, // - @Meta( description = "The Help message line before explaining the different modes") + @Meta(description = "The Help message line before explaining the different modes") CLI_HELP_MODES, // - @Meta( description = "The Help message line for help usage") + @Meta(description = "The Help message line for help usage") CLI_HELP_MODE_HELP, // - @Meta( description = "The Help message line for contact manager usage") + @Meta(description = "The Help message line for contact manager usage") CLI_HELP_MODE_CONTACT_MANAGER, // - @Meta( description = "The Help message line for contact manager usage") + @Meta(description = "The Help message line for contact manager usage") CLI_HELP_MODE_I18N, // - @Meta( description = "The Help message line for jVCard server usage") + @Meta(description = "The Help message line for jVCard server usage") CLI_HELP_MODE_SERVER, // - @Meta( description = "The Help message line for --load-photo usage") + @Meta(description = "The Help message line for --load-photo usage") CLI_HELP_MODE_LOAD_PHOTO, // - @Meta( description = "The Help message line for --save-photo usage") + @Meta(description = "The Help message line for --save-photo usage") CLI_HELP_MODE_SAVE_PHOTO, // - @Meta( description = "The Help message line for config save usage") + @Meta(description = "The Help message line for config save usage") CLI_HELP_MODE_SAVE_CONFIG, // - @Meta( description = "The Help message line before the list of options") + @Meta(description = "The Help message line before the list of options") CLI_HELP_OPTIONS, // - @Meta( description = "The Help message line for: --") + @Meta(description = "The Help message line for: --") CLI_HELP_DD, // - @Meta( description = "The Help message line for: --") + @Meta(description = "The Help message line for: --") CLI_HELP_LANG, // - @Meta( description = "The Help message line for: --") + @Meta(description = "The Help message line for: --") CLI_HELP_GUI, // - @Meta( description = "The Help message line for: --") + @Meta(description = "The Help message line for: --") CLI_HELP_TUI, // - @Meta( description = "The Help message line for: --") + @Meta(description = "The Help message line for: --") CLI_HELP_NOUTF_OPTION, // - @Meta( description = "The Help message line for: --") + @Meta(description = "The Help message line for: --") CLI_HELP_CONFIG, // - @Meta( description = "The Help message footer about files and jvcard:// links") + @Meta(description = "The Help message footer about files and jvcard:// links") CLI_HELP_FOOTER, // - @Meta( info = "%s = the error", description = "Syntax error: SOME TEXT") + @Meta(info = "%s = the error", description = "Syntax error: SOME TEXT") CLI_SERR, // - @Meta( description = "More than one mode given") + @Meta(description = "More than one mode given") CLI_SERR_MODES, // - @Meta( description = "--lang is required") + @Meta(description = "--lang is required") CLI_SERR_NOLANG, // - @Meta( description = "The dir is required") + @Meta(description = "The dir is required") CLI_SERR_NODIR, // - @Meta( description = "The port is required") + @Meta(description = "The port is required") CLI_SERR_NOPORT, // - @Meta( description = "The format is required") + @Meta(description = "The format is required") CLI_SERR_NOFORMAT, // - @Meta( info = "%s = bad port", description = "The port is not valid") + @Meta(info = "%s = bad port", description = "The port is not valid") CLI_SERR_BADPORT, // - @Meta( info = "%s = mode", description = "Card files are not supported in mode %s") + @Meta(info = "%s = mode", description = "Card files are not supported in mode %s") CLI_SERR_CANNOT_CARDS, // - @Meta( info = "%s = the error", description = "Error: SOME TEXT") + @Meta(info = "%s = the error", description = "Error: SOME TEXT") CLI_ERR, // - @Meta( description = "No files given") + @Meta(description = "No files given") CLI_ERR_NOFILES, // - @Meta( info = "%s = dir", description = "Cannot create conf dir %s") + @Meta(info = "%s = dir", description = "Cannot create conf dir %s") CLI_ERR_CANNOT_CREATE_CONFDIR, // - @Meta( description = "Remoting not available") + @Meta(description = "Remoting not available") CLI_ERR_NO_REMOTING, // - @Meta( description = "TUI not available") + @Meta(description = "TUI not available") CLI_ERR_NO_TUI, // - @Meta( info = "%s = dir", description = "Cannot create/update language in dir %s") + @Meta(info = "%s = dir", description = "Cannot create/update language in dir %s") CLI_ERR_CANNOT_CREATE_LANG, // - @Meta( info = "%s = card", description = "Cannot open card %s") + @Meta(info = "%s = card", description = "Cannot open card %s") CLI_ERR_CANNOT_OPEN, // @Meta(info = "%s = contact FN", description = "Cannot save photo of contact %s") CLI_ERR_CANNOT_SAVE_PHOTO, // - @Meta( description = "Cannot start the program with the given cards") + @Meta(description = "Cannot start the program with the given cards") CLI_ERR_CANNOT_START, // -}; +} diff --git a/src/be/nikiroo/jvcard/tui/ImageTextControl.java b/src/be/nikiroo/jvcard/tui/ImageTextControl.java index 22621a3..6a0a5ea 100644 --- a/src/be/nikiroo/jvcard/tui/ImageTextControl.java +++ b/src/be/nikiroo/jvcard/tui/ImageTextControl.java @@ -90,7 +90,7 @@ public class ImageTextControl extends Panel { setImage(image); return this; - }; + } /** * Set/reset the {@link ImageText} to render. diff --git a/src/be/nikiroo/jvcard/tui/KeyAction.java b/src/be/nikiroo/jvcard/tui/KeyAction.java index 9a56cd9..21e9dac 100644 --- a/src/be/nikiroo/jvcard/tui/KeyAction.java +++ b/src/be/nikiroo/jvcard/tui/KeyAction.java @@ -241,6 +241,7 @@ public class KeyAction { * * @return an error message if any */ + @SuppressWarnings("unused") public String callback(String answer) { return null; } diff --git a/src/be/nikiroo/jvcard/tui/MainWindow.java b/src/be/nikiroo/jvcard/tui/MainWindow.java index 39560a4..617d8a5 100644 --- a/src/be/nikiroo/jvcard/tui/MainWindow.java +++ b/src/be/nikiroo/jvcard/tui/MainWindow.java @@ -460,19 +460,16 @@ public class MainWindow extends BasicWindow { UiColors.themeLabel(ColorOption.TITLE_VARIABLE, lblTitle); } - Label lblCount = null; - if (countStr != null) { - lblCount = new Label(countStr); - UiColors.themeLabel(ColorOption.TITLE_COUNT, lblCount); - } + Label lblCount = new Label(countStr); + UiColors.themeLabel(ColorOption.TITLE_COUNT, lblCount); titlePanel.removeAllComponents(); titlePanel.addComponent(lblPrefix, BorderLayout.Location.LEFT); - if (lblTitle != null) + if (lblTitle != null) { titlePanel.addComponent(lblTitle, BorderLayout.Location.CENTER); - if (lblCount != null) - titlePanel.addComponent(lblCount, BorderLayout.Location.RIGHT); + } + titlePanel.addComponent(lblCount, BorderLayout.Location.RIGHT); } } diff --git a/src/be/nikiroo/jvcard/tui/UiColors.java b/src/be/nikiroo/jvcard/tui/UiColors.java index a851d4e..61bb692 100644 --- a/src/be/nikiroo/jvcard/tui/UiColors.java +++ b/src/be/nikiroo/jvcard/tui/UiColors.java @@ -3,7 +3,6 @@ package be.nikiroo.jvcard.tui; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.Writer; import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; @@ -11,8 +10,6 @@ import java.util.Properties; import be.nikiroo.jvcard.resources.ColorBundle; import be.nikiroo.jvcard.resources.ColorOption; -import be.nikiroo.jvcard.resources.Target; -import be.nikiroo.utils.resources.Bundle; import com.googlecode.lanterna.TextColor; import com.googlecode.lanterna.graphics.PropertiesTheme; diff --git a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java index 9bab007..791d57c 100644 --- a/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java +++ b/src/be/nikiroo/jvcard/tui/panes/ContactDetails.java @@ -116,22 +116,27 @@ public class ContactDetails extends MainContent { boolean hl = false; boolean all = false; - if (info.contains("+") || info.contains("#")) + if (info.contains("+") || info.contains("#")) { hl = true; - if (info.contains("*") || info.contains("#")) + } + if (info.contains("*") || info.contains("#")) { all = true; + } if (all || hl || info.contains("=")) { ColorOption el = hl ? ColorOption.VIEW_CONTACT_HIGHLIGHT : ColorOption.VIEW_CONTACT_NORMAL; int index = info.indexOf('='); - if (index < 0) + if (index < 0) { index = info.indexOf('+'); - if (index < 0) + } + if (index < 0) { index = info.indexOf('#'); - if (index < 0) + } + if (index < 0) { index = info.indexOf('*'); + } String label = info.substring(0, index); String field = info.substring(index + 1); @@ -152,8 +157,9 @@ public class ContactDetails extends MainContent { } } else { String val = contact.getPreferredDataValue(field); - if (val == null) + if (val == null) { val = ""; + } infoPanel.addComponent(UiColors.createLabel(el, StringUtils.padString(label, labelSize) + val)); } @@ -170,8 +176,9 @@ public class ContactDetails extends MainContent { ColorOption.VIEW_CONTACT_NORMAL, "")); String notes = contact.getPreferredDataValue("NOTE"); - if (notes == null) + if (notes == null) { notes = ""; + } note.setText(notes); Data photo = contact.getPreferredData("PHOTO"); @@ -188,7 +195,6 @@ public class ContactDetails extends MainContent { if (encoding != null && encoding.getValue() != null && encoding.getValue().equalsIgnoreCase("b")) { - try { image = ImageUtils.fromBase64(photo.getValue()); } catch (Exception e) { @@ -270,15 +276,17 @@ public class ContactDetails extends MainContent { private void setImage(Image image) { this.image = image; - if (txtImage != null && top.containsComponent(txtImage)) + if (txtImage != null && top.containsComponent(txtImage)) { top.removeComponent(txtImage); + } TerminalSize size = getTxtSize(); if (size != null) { - if (txtImage != null) + if (txtImage != null) { txtImage.setSize(size); - else + } else { txtImage = new ImageTextControl(image, size); + } } if (size != null) { @@ -299,15 +307,16 @@ public class ContactDetails extends MainContent { && getSize().getRows() > 0) { if (fullscreenImage) { return getSize(); - } else { - // TODO: configure size? - int w = getSize().getColumns() - 40; - int h = getSize().getRows() - 9; - if (w <= 0 || h <= 0) - return null; + } - return new TerminalSize(w, h); + // TODO: configure size? + int w = getSize().getColumns() - 40; + int h = getSize().getRows() - 9; + if (w <= 0 || h <= 0) { + return null; } + + return new TerminalSize(w, h); } return null; diff --git a/src/be/nikiroo/jvcard/tui/panes/FileList.java b/src/be/nikiroo/jvcard/tui/panes/FileList.java index 1172378..55f85cc 100644 --- a/src/be/nikiroo/jvcard/tui/panes/FileList.java +++ b/src/be/nikiroo/jvcard/tui/panes/FileList.java @@ -96,7 +96,7 @@ public class FileList extends MainContentList { parts.add(new TextPart(name, el)); return parts; - }; + } @Override public List getKeyBindings() { diff --git a/src/be/nikiroo/jvcard/tui/panes/MainContent.java b/src/be/nikiroo/jvcard/tui/panes/MainContent.java index 0d873da..c63afd9 100644 --- a/src/be/nikiroo/jvcard/tui/panes/MainContent.java +++ b/src/be/nikiroo/jvcard/tui/panes/MainContent.java @@ -75,6 +75,7 @@ abstract public class MainContent extends Panel { * * @return the error message to display if any */ + @SuppressWarnings("unused") public String move(int x, int y) { return null; } diff --git a/src/be/nikiroo/jvcard/tui/panes/MainContentList.java b/src/be/nikiroo/jvcard/tui/panes/MainContentList.java index 1b0eb1b..f7aaec4 100644 --- a/src/be/nikiroo/jvcard/tui/panes/MainContentList.java +++ b/src/be/nikiroo/jvcard/tui/panes/MainContentList.java @@ -88,6 +88,7 @@ abstract public class MainContentList extends MainContent implements Runnable { * Will be set to {@code true} if the list box currently * has input focus, otherwise {@code false} */ + @Override public void drawItem(TextGUIGraphics graphics, ActionListBox listBox, int index, Runnable item, boolean selected, boolean focused) { @@ -225,7 +226,8 @@ abstract public class MainContentList extends MainContent implements Runnable { * * @return the text representation */ - protected List getLabel(int index, int width, boolean selected, + protected List getLabel(int index, + @SuppressWarnings("unused") int width, boolean selected, boolean focused) { List parts = new LinkedList();