Skip to content

Commit

Permalink
Issue #440: resolves LogicConditionNeedOptimizationCheck
Browse files Browse the repository at this point in the history
  • Loading branch information
rnveach authored and Calixte committed Jan 28, 2023
1 parent 84f1b61 commit 3e27bdc
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void runAudit(IProject project, IProgressMonitor monitor)
// System.out.println("----> Auditing: " + mFiles.size());

// skip if there are no files to check
if (mFiles.isEmpty() || project == null) {
if (project == null || mFiles.isEmpty()) {
return;
}

Expand Down Expand Up @@ -312,7 +312,7 @@ public void addError(AuditEvent error) {

SeverityLevel severity = error.getSeverityLevel();

if (!severity.equals(SeverityLevel.IGNORE) && mResource != null) {
if (mResource != null && !severity.equals(SeverityLevel.IGNORE)) {

RuleMetadata metaData = MetadataFactory.getRuleMetadata(error.getSourceName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private static void loadFromPersistence() throws CheckstylePluginException {
sConfigurations.addAll(getGlobalCheckConfigurations(root));

for (ICheckConfiguration config : sConfigurations) {
if (config.getName().equals(defaultConfigName) && config != sDefaultBuiltInConfig) {
if (config != sDefaultBuiltInConfig && config.getName().equals(defaultConfigName)) {
sDefaultCheckConfig = config;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public String resolve(String property) {

String value = null;

if ((SAMEDIR_LOC.equals(property) || CONFIG_LOC.equals(property))
&& mBuiltInConfigLocation != null) {
if (mBuiltInConfigLocation != null
&& (SAMEDIR_LOC.equals(property) || CONFIG_LOC.equals(property))) {

int lastSlash = mBuiltInConfigLocation.lastIndexOf("/"); //$NON-NLS-1$
if (lastSlash > -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ public boolean equals(Object obj) {
return true;
}
ConfigurationType rhs = (ConfigurationType) obj;
return Objects.equals(mName, rhs.mName) && Objects.equals(mInternalName, rhs.mInternalName)
&& mIsCreatable == rhs.mIsCreatable && mIsEditable == rhs.mIsEditable
&& mIsConfigurable == rhs.mIsConfigurable;
return mIsCreatable == rhs.mIsCreatable && mIsEditable == rhs.mIsEditable
&& mIsConfigurable == rhs.mIsConfigurable
&& Objects.equals(mName, rhs.mName)
&& Objects.equals(mInternalName, rhs.mInternalName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public String resolve(String property) {
String value = null;
if (WORKSPACE_LOC.equals(property)) {
value = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();
} else if ((PROJECT_LOC.equals(property) || BASEDIR_LOC.equals(property)) && mProject != null) {
} else if (mProject != null && (PROJECT_LOC.equals(property) || BASEDIR_LOC.equals(property))) {
value = mProject.getLocation().toString();
} else if ((SAMEDIR_LOC.equals(property) || CONFIG_LOC.equals(property))
&& mConfigLocation != null) {
} else if (mConfigLocation != null
&& (SAMEDIR_LOC.equals(property) || CONFIG_LOC.equals(property))) {
String configLocWOBackslashes = mConfigLocation.replace('\\', '/');

int lastSlash = configLocWOBackslashes.lastIndexOf("/"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ private void openModule(ISelection selection) {
RuleConfigurationEditDialog dialog = new RuleConfigurationEditDialog(getShell(),
workingCopy, !mConfigurable,
Messages.CheckConfigurationConfigureDialog_titleModuleConfigEditor);
if (Window.OK == dialog.open() && mConfigurable) {
if (mConfigurable && Window.OK == dialog.open()) {
mModules.set(mModules.indexOf(module), workingCopy);
mIsDirty = true;
mTableViewer.refresh(true);
Expand Down Expand Up @@ -690,7 +690,7 @@ private void newModule(ISelection selection) {
RuleConfigurationEditDialog dialog = new RuleConfigurationEditDialog(getShell(),
workingCopy, !mConfigurable,
Messages.CheckConfigurationConfigureDialog_titleNewModule);
if (Window.OK == dialog.open() && mConfigurable) {
if (mConfigurable && Window.OK == dialog.open()) {
mModules.add(workingCopy);
mIsDirty = true;
mTableViewer.refresh(true);
Expand Down Expand Up @@ -719,7 +719,7 @@ private void newModule(ISelection selection) {
*/
private void removeModule(ISelection selection) {

if (!selection.isEmpty() && mConfigurable) {
if (mConfigurable && !selection.isEmpty()) {

if (MessageDialog.openConfirm(getShell(),
Messages.CheckConfigurationConfigureDialog_titleRemoveModules,
Expand Down Expand Up @@ -950,7 +950,7 @@ public String getColumnText(Object element, int columnIndex) {

@Override
public Comparable<?> getComparableValue(Object element, int col) {
if (element instanceof Module && col == 0) {
if (col == 0 && element instanceof Module) {
return Severity.ignore.equals(((Module) element).getSeverity()) ? Integer.valueOf(0)
: Integer.valueOf(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,12 @@ public boolean performOk() {
String promptRebuildPref = CheckstyleUIPluginPrefs
.getString(CheckstyleUIPluginPrefs.PREF_ASK_BEFORE_REBUILD);

boolean doRebuild = MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref) && needRebuild;
boolean doRebuild = needRebuild && MessageDialogWithToggle.ALWAYS.equals(promptRebuildPref);

//
// Prompt for rebuild
//
if (MessageDialogWithToggle.PROMPT.equals(promptRebuildPref) && needRebuild) {
if (needRebuild && MessageDialogWithToggle.PROMPT.equals(promptRebuildPref)) {
MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(getShell(),
Messages.CheckstylePropertyPage_titleRebuild,
Messages.CheckstylePropertyPage_msgRebuild,
Expand Down Expand Up @@ -564,7 +564,7 @@ public void widgetSelected(SelectionEvent e) {

boolean showWarning = CheckstyleUIPluginPrefs
.getBoolean(CheckstyleUIPluginPrefs.PREF_FILESET_WARNING);
if (mProjectConfig.isUseSimpleConfig() && showWarning) {
if (showWarning && mProjectConfig.isUseSimpleConfig()) {
MessageDialogWithToggle dialog = new MessageDialogWithToggle(getShell(),
Messages.CheckstylePropertyPage_titleWarnFilesets, null,
Messages.CheckstylePropertyPage_msgWarnFilesets, MessageDialog.WARNING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void verifyText(VerifyEvent e) {
boolean doit = true;

// only let digits pass (and del, backspace)
if (!(Character.isDigit(e.character) || e.character == SWT.DEL || e.character == SWT.BS)) {
if (!(e.character == SWT.DEL || e.character == SWT.BS || Character.isDigit(e.character))) {
doit = false;
}

Expand Down

0 comments on commit 3e27bdc

Please sign in to comment.