From 7a5ff103697c8cf94749b0edae384559b5c555ca Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 6 Apr 2023 22:46:48 +0200 Subject: [PATCH 01/17] Management of configuration for remote SonarLint --- pom.xml | 5 + .../SonarLintConnectionConfiguration.java | 60 ++++ ...LintConnectionConfigurationManagement.java | 120 ++++++++ ...nnectionConfigurationListCellRenderer.java | 47 +++ .../remote/ui/SonarLintSonarCloudPanel.form | 278 +++++++++++++++++ .../remote/ui/SonarLintSonarCloudPanel.java | 280 ++++++++++++++++++ .../sonarlint4netbeans/ui/SonarLintPanel.form | 3 +- .../sonarlint4netbeans/ui/SonarLintPanel.java | 11 +- .../remote/ui/Bundle.properties | 17 ++ 9 files changed, 819 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties diff --git a/pom.xml b/pom.xml index 8cde2c7..2ebfb98 100644 --- a/pom.xml +++ b/pom.xml @@ -406,6 +406,11 @@ org-openide-modules ${org.netbeans.version} + + org.netbeans.api + org-netbeans-modules-keyring + ${org.netbeans.version} + org.junit.jupiter junit-jupiter-api diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java new file mode 100644 index 0000000..578f625 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintConnectionConfiguration { + private final String connectionId; + private final String projectKey; + private final String baseURL; + private final boolean isSonarCloud; + private final String organization; + + public SonarLintConnectionConfiguration(String connectionId, String projectKey, String baseURL, boolean isSonarCloud, String organization) { + this.connectionId = connectionId; + this.projectKey = projectKey; + this.baseURL = baseURL; + this.isSonarCloud = isSonarCloud; + this.organization = organization; + } + + public String getConnectionId() { + return connectionId; + } + + public String getProjectKey() { + return projectKey; + } + + public String getBaseURL() { + return baseURL; + } + + public boolean isIsSonarCloud() { + return isSonarCloud; + } + + public String getOrganization() { + return organization; + } + +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java new file mode 100644 index 0000000..ad144bd --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.util.List; +import java.util.Optional; +import java.util.prefs.Preferences; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.netbeans.api.keyring.Keyring; +import org.openide.util.NbPreferences; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@ServiceProvider(service = SonarLintConnectionConfigurationManagement.class) +public class SonarLintConnectionConfigurationManagement { + + private final Gson gson = new Gson(); + + /** + * Default constructor for Lookup + */ + public SonarLintConnectionConfigurationManagement() + { +/* + Project project = Lookup.getDefault().lookup(Project.class); + PropertyEvaluator evaluator = project.getLookup().lookup(PropertyEvaluator.class); + String branch = evaluator.getProperty("branch"); + System.out.println("Current branch: " + branch); + + Project project = FileUtil.toFileObject(FileUtil.toFile(project)).getLookup().lookup(Project.class); + Project mainProject = ProjectUtils.getMainProject(project); + System.out.println("Main project: " + mainProject.getProjectDirectory().getName()); + + */ + } + + public Optional getAuthTokenFromConnectionId(String connectionId) { + return Optional.ofNullable( + Keyring.read(SonarLintConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId) + ).map(String::new); + } + + public void saveAuthTokenFromConnectionId(String connectionId, String token) { + Keyring.save( + SonarLintConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId, + token.toCharArray(), + "Auth token for SonarLint Remote connectionId \"" + connectionId + "\"" + ); + } + + public void deleteAuthTokenFromConnectionId(String connectionId) { + Keyring.delete( + SonarLintConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId + ); + } + + public Optional getSonarLintConnectionConfigurationFromConnectionId(String connectionId) { + return getAllSonarLintConnectionConfigurations().stream() + .filter(c -> c.getConnectionId().equals(connectionId)) + .findFirst(); + } + + public void deleteSonarLintConnectionConfigurationFromConnectionId(String connectionId) { + Preferences preferences = NbPreferences.forModule(SonarLintConnectionConfiguration.class); + preferences.put( + "connections", + gson.toJson( + getAllSonarLintConnectionConfigurations() + .stream() + .filter(c -> !c.getConnectionId().equals(connectionId) + ).collect(Collectors.toList()) + ) + ); + } + + public List getAllSonarLintConnectionConfigurations() { + Preferences preferences = NbPreferences.forModule(SonarLintConnectionConfiguration.class); + return gson.fromJson( + preferences.get("connections", "[]"), + new TypeToken>() {}.getType() + ); + } + + public void saveSonarLintConnectionConfiguration(SonarLintConnectionConfiguration sonarLintConnectionConfiguration) { + Preferences preferences = NbPreferences.forModule(SonarLintConnectionConfiguration.class); + preferences.put( + "connections", + gson.toJson( + Stream.concat( + getAllSonarLintConnectionConfigurations() + .stream() + .filter(c -> !c.getConnectionId().equals(sonarLintConnectionConfiguration.getConnectionId())), + Stream.of(sonarLintConnectionConfiguration) + ).collect(Collectors.toList()) + ) + ); + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java new file mode 100644 index 0000000..ed7112c --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.ui; + +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintConnectionConfiguration; +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintConnectionConfigurationListCellRenderer extends DefaultListCellRenderer { + + + @Override + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus + ) { + DefaultListCellRenderer listCellRendererComponent = (DefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value != null) { + listCellRendererComponent.setText(((SonarLintConnectionConfiguration)value).getConnectionId()); + } + return listCellRendererComponent; + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form new file mode 100644 index 0000000..e3be0d5 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form @@ -0,0 +1,278 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java new file mode 100644 index 0000000..ce8ae8e --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java @@ -0,0 +1,280 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.ui; + +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintConnectionConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintConnectionConfigurationManagement; +import org.openide.util.Lookup; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@SuppressWarnings({ + "java:S1450" // "Private fields used as local variables in methods" disabled because managed by netbeans +}) +public class SonarLintSonarCloudPanel extends javax.swing.JPanel { + + /** + * Creates new form SonarLintSonarCloudPanel + */ + public SonarLintSonarCloudPanel() { + initComponents(); + connectionCnfigurationComboBox.setRenderer(new SonarLintConnectionConfigurationListCellRenderer()); + initConnectionCnfigurationComboBox(); + } + + private void initConnectionCnfigurationComboBox() + { + connectionCnfigurationComboBox.removeAllItems(); + getSonarLintConnectionConfigurationManagement().getAllSonarLintConnectionConfigurations() + .forEach(connectionCnfigurationComboBox::addItem); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + connectionListPanel = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + connectionCnfigurationComboBox = new javax.swing.JComboBox<>(); + editConnectionConfiguration = new javax.swing.JButton(); + removeConnectionConfiguration = new javax.swing.JButton(); + connectionEditPanel = new javax.swing.JPanel(); + connectionEditDataPanel = new javax.swing.JPanel(); + connectionIdLabel = new javax.swing.JLabel(); + connectionIdTextField = new javax.swing.JTextField(); + baseURLLabel = new javax.swing.JLabel(); + baseURLTextField = new javax.swing.JTextField(); + isSonarCloudLabel = new javax.swing.JLabel(); + isSonarCloudCheckBox = new javax.swing.JCheckBox(); + projectKeyLabel = new javax.swing.JLabel(); + projectKeyTextField = new javax.swing.JTextField(); + organizationLabel = new javax.swing.JLabel(); + organizationTextField = new javax.swing.JTextField(); + authTokenLabel = new javax.swing.JLabel(); + authTokenTextField = new javax.swing.JTextField(); + connectionSavePanel = new javax.swing.JPanel(); + saveConfiguration = new javax.swing.JButton(); + + setLayout(new java.awt.BorderLayout(5, 5)); + + connectionListPanel.setLayout(new java.awt.BorderLayout(5, 5)); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.jLabel1.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(editConnectionConfiguration, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.editConnectionConfiguration.text")); // NOI18N + editConnectionConfiguration.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + editConnectionConfiguration(evt); + } + }); + + org.openide.awt.Mnemonics.setLocalizedText(removeConnectionConfiguration, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.removeConnectionConfiguration.text")); // NOI18N + removeConnectionConfiguration.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + removeConnectionConfiguration(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(5, 5, 5) + .addComponent(connectionCnfigurationComboBox, 0, 297, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(editConnectionConfiguration) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(removeConnectionConfiguration) + .addGap(5, 5, 5)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(connectionCnfigurationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(editConnectionConfiguration) + .addComponent(removeConnectionConfiguration)) + .addContainerGap()) + ); + + connectionListPanel.add(jPanel1, java.awt.BorderLayout.NORTH); + + add(connectionListPanel, java.awt.BorderLayout.NORTH); + + connectionEditPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.connectionEditPanel.border.title"))); // NOI18N + connectionEditPanel.setLayout(new java.awt.BorderLayout(5, 5)); + + connectionEditDataPanel.setLayout(new java.awt.GridLayout(6, 2, 5, 5)); + + org.openide.awt.Mnemonics.setLocalizedText(connectionIdLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.connectionIdLabel.text")); // NOI18N + connectionEditDataPanel.add(connectionIdLabel); + + connectionIdTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.connectionIdTextField.text")); // NOI18N + connectionEditDataPanel.add(connectionIdTextField); + + org.openide.awt.Mnemonics.setLocalizedText(baseURLLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.baseURLLabel.text")); // NOI18N + connectionEditDataPanel.add(baseURLLabel); + + baseURLTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.baseURLTextField.text")); // NOI18N + connectionEditDataPanel.add(baseURLTextField); + + org.openide.awt.Mnemonics.setLocalizedText(isSonarCloudLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.isSonarCloudLabel.text")); // NOI18N + connectionEditDataPanel.add(isSonarCloudLabel); + + org.openide.awt.Mnemonics.setLocalizedText(isSonarCloudCheckBox, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.isSonarCloudCheckBox.text")); // NOI18N + connectionEditDataPanel.add(isSonarCloudCheckBox); + + org.openide.awt.Mnemonics.setLocalizedText(projectKeyLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.projectKeyLabel.text")); // NOI18N + connectionEditDataPanel.add(projectKeyLabel); + + projectKeyTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.projectKeyTextField.text")); // NOI18N + connectionEditDataPanel.add(projectKeyTextField); + + org.openide.awt.Mnemonics.setLocalizedText(organizationLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.organizationLabel.text")); // NOI18N + connectionEditDataPanel.add(organizationLabel); + + organizationTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.organizationTextField.text")); // NOI18N + connectionEditDataPanel.add(organizationTextField); + + org.openide.awt.Mnemonics.setLocalizedText(authTokenLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.authTokenLabel.text")); // NOI18N + connectionEditDataPanel.add(authTokenLabel); + + authTokenTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.authTokenTextField.text")); // NOI18N + connectionEditDataPanel.add(authTokenTextField); + + connectionEditPanel.add(connectionEditDataPanel, java.awt.BorderLayout.NORTH); + + org.openide.awt.Mnemonics.setLocalizedText(saveConfiguration, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.saveConfiguration.text")); // NOI18N + saveConfiguration.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + saveConfigurationActionPerformed(evt); + } + }); + + javax.swing.GroupLayout connectionSavePanelLayout = new javax.swing.GroupLayout(connectionSavePanel); + connectionSavePanel.setLayout(connectionSavePanelLayout); + connectionSavePanelLayout.setHorizontalGroup( + connectionSavePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(connectionSavePanelLayout.createSequentialGroup() + .addGap(0, 269, Short.MAX_VALUE) + .addComponent(saveConfiguration) + .addGap(0, 269, Short.MAX_VALUE)) + ); + connectionSavePanelLayout.setVerticalGroup( + connectionSavePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, connectionSavePanelLayout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(saveConfiguration) + .addGap(0, 0, 0)) + ); + + connectionEditPanel.add(connectionSavePanel, java.awt.BorderLayout.SOUTH); + + add(connectionEditPanel, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + + private SonarLintConnectionConfigurationManagement getSonarLintConnectionConfigurationManagement() + { + return Lookup.getDefault().lookup(SonarLintConnectionConfigurationManagement.class); + } + + private void saveConfigurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveConfigurationActionPerformed + String connectionId = connectionIdTextField.getText(); + getSonarLintConnectionConfigurationManagement().saveSonarLintConnectionConfiguration( + new SonarLintConnectionConfiguration( + connectionId, + projectKeyTextField.getText(), + baseURLTextField.getText(), + isSonarCloudCheckBox.isSelected(), + organizationTextField.getText() + ) + ); + getSonarLintConnectionConfigurationManagement().saveAuthTokenFromConnectionId( + connectionId, + authTokenTextField.getText() + ); + initConnectionCnfigurationComboBox(); + }//GEN-LAST:event_saveConfigurationActionPerformed + + private void editConnectionConfiguration(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editConnectionConfiguration + SonarLintConnectionConfiguration sonarLintConnectionConfiguration = + (SonarLintConnectionConfiguration)connectionCnfigurationComboBox.getSelectedItem(); + String connectionId = sonarLintConnectionConfiguration.getConnectionId(); + if (sonarLintConnectionConfiguration != null) { + connectionIdTextField.setText(connectionId); + projectKeyTextField.setText(sonarLintConnectionConfiguration.getProjectKey()); + baseURLTextField.setText(sonarLintConnectionConfiguration.getBaseURL()); + isSonarCloudCheckBox.setSelected(sonarLintConnectionConfiguration.isIsSonarCloud()); + organizationTextField.setText(sonarLintConnectionConfiguration.getOrganization()); + getSonarLintConnectionConfigurationManagement() + .getAuthTokenFromConnectionId(connectionId) + .ifPresent(authTokenTextField::setText); + } + }//GEN-LAST:event_editConnectionConfiguration + + private void removeConnectionConfiguration(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeConnectionConfiguration + SonarLintConnectionConfiguration sonarLintConnectionConfiguration = + (SonarLintConnectionConfiguration)connectionCnfigurationComboBox.getSelectedItem(); + if (sonarLintConnectionConfiguration != null) { + SonarLintConnectionConfigurationManagement sonarLintConnectionConfigurationManagement = getSonarLintConnectionConfigurationManagement(); + sonarLintConnectionConfigurationManagement.deleteAuthTokenFromConnectionId(sonarLintConnectionConfiguration.getConnectionId()); + sonarLintConnectionConfigurationManagement.deleteSonarLintConnectionConfigurationFromConnectionId(sonarLintConnectionConfiguration.getConnectionId()); + initConnectionCnfigurationComboBox(); + } + }//GEN-LAST:event_removeConnectionConfiguration + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel authTokenLabel; + private javax.swing.JTextField authTokenTextField; + private javax.swing.JLabel baseURLLabel; + private javax.swing.JTextField baseURLTextField; + private javax.swing.JComboBox connectionCnfigurationComboBox; + private javax.swing.JPanel connectionEditDataPanel; + private javax.swing.JPanel connectionEditPanel; + private javax.swing.JLabel connectionIdLabel; + private javax.swing.JTextField connectionIdTextField; + private javax.swing.JPanel connectionListPanel; + private javax.swing.JPanel connectionSavePanel; + private javax.swing.JButton editConnectionConfiguration; + private javax.swing.JCheckBox isSonarCloudCheckBox; + private javax.swing.JLabel isSonarCloudLabel; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel1; + private javax.swing.JLabel organizationLabel; + private javax.swing.JTextField organizationTextField; + private javax.swing.JLabel projectKeyLabel; + private javax.swing.JTextField projectKeyTextField; + private javax.swing.JButton removeConnectionConfiguration; + private javax.swing.JButton saveConfiguration; + // End of variables declaration//GEN-END:variables +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.form b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.form index 55b0bfd..a44ff6c 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.form +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.form @@ -128,12 +128,13 @@ - + + diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java index 97fbde6..307a2b0 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java @@ -22,6 +22,7 @@ import com.github.philippefichet.sonarlint4netbeans.SonarLintEngine; import com.github.philippefichet.sonarlint4netbeans.SonarLintOptions; import com.github.philippefichet.sonarlint4netbeans.SonarLintUtils; +import com.github.philippefichet.sonarlint4netbeans.remote.ui.SonarLintSonarCloudPanel; import java.awt.BorderLayout; import java.util.HashMap; import java.util.Map; @@ -113,6 +114,9 @@ private void showPanelFromCategory(SonarLintEngine engine, String category) if ("Plugins".equals(category)) { initPluginsPanel(engine); } + if ("Remote".equals(category)) { + initSonarLintRemotePanel(); + } optionPanel.revalidate(); optionPanel.repaint(); } @@ -208,6 +212,11 @@ private void initPluginsPanel(SonarLintEngine sonarLintEngine) { ); } + private void initSonarLintRemotePanel() { + optionPanel.removeAll(); + optionPanel.add(new SonarLintSonarCloudPanel()); + } + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -230,7 +239,7 @@ private void initComponents() { categoriesPanel.setPreferredSize(new java.awt.Dimension(100, 100)); categoriesList.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Options", "Rules", "Analyzers", "Properties", "Plugins" }; + String[] strings = { "Options", "Rules", "Analyzers", "Properties", "Plugins", "Remote" }; public int getSize() { return strings.length; } public String getElementAt(int i) { return strings[i]; } }); diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties new file mode 100644 index 0000000..d28727f --- /dev/null +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties @@ -0,0 +1,17 @@ +SonarLintSonarCloudPanel.jLabel1.text=Existing connections : +SonarLintSonarCloudPanel.connectionEditPanel.border.title=Edit connection +SonarLintSonarCloudPanel.saveConfiguration.text=Save +SonarLintSonarCloudPanel.connectionIdLabel.text=connectionId +SonarLintSonarCloudPanel.connectionIdTextField.text=SonarQubeLocal +SonarLintSonarCloudPanel.baseURLLabel.text=baseURL +SonarLintSonarCloudPanel.baseURLTextField.text=http://localhost:9000 +SonarLintSonarCloudPanel.isSonarCloudLabel.text=Is sonar cloud +SonarLintSonarCloudPanel.isSonarCloudCheckBox.text= +SonarLintSonarCloudPanel.projectKeyLabel.text=projectKey +SonarLintSonarCloudPanel.projectKeyTextField.text= +SonarLintSonarCloudPanel.organizationLabel.text=organization +SonarLintSonarCloudPanel.organizationTextField.text= +SonarLintSonarCloudPanel.authTokenLabel.text=auth token +SonarLintSonarCloudPanel.authTokenTextField.text= +SonarLintSonarCloudPanel.editConnectionConfiguration.text=Edit +SonarLintSonarCloudPanel.removeConnectionConfiguration.text=Remove From 64d8daf5b516a10a6bfb85f1f060cd639b743973 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Sun, 10 Dec 2023 17:34:03 +0100 Subject: [PATCH 02/17] Project configuration to remote analyze - Sync project - Analyze --- README.adoc | 4 +- pom.xml | 39 ++- .../sonarlint4netbeans/SonarLintOptions.java | 1 + .../SonarLintTaskScanner.java | 1 - .../sonarlint4netbeans/SonarLintUtils.java | 153 ++++++++-- .../SonarLintAnnotationHandler.java | 5 + .../SonarLintProjectPreferenceScope.java | 4 +- .../ui/SonarLintProjectCustomizerPanel.form | 216 +++++++++++++-- .../ui/SonarLintProjectCustomizerPanel.java | 232 +++++++++++++++- .../remote/SonarLintRemoteEngine.java | 262 ++++++++++++++++++ .../remote/SonarLintRemoteEngineUtils.java | 52 ++++ ...narLintRemoteConnectionConfiguration.java} | 18 +- ...oteConnectionConfigurationManagement.java} | 28 +- .../SonarLintRemoteProjectConfiguration.java | 124 +++++++++ .../SonarLintRemoteEnginSyncListener.java | 34 +++ ...rLintRemoteSyncListenerProgressHandle.java | 62 +++++ .../SonarLintSyncTaskProjectOpenedHook.java | 82 ++++++ .../SonarLintRemoteSynchronizationTask.java | 209 ++++++++++++++ .../remote/synchronization/TaskWrapper.java | 72 +++++ ...nnectionConfigurationListCellRenderer.java | 4 +- .../remote/ui/SonarLintSonarCloudPanel.form | 36 +-- .../remote/ui/SonarLintSonarCloudPanel.java | 82 +++--- .../SonarLintIssueWrapperForServerIssue.java | 149 ++++++++++ ...LintRemoteConsumerProgressInputStream.java | 124 +++++++++ .../wrapper/SonarLintRemoteHttpClient.java | 112 ++++++++ .../wrapper/SonarLintRemoteHttpResponse.java | 83 ++++++ .../ui/SonarRuleDetailsPanel.java | 2 + .../ui/SonarRuleDetailsTopComponent.java | 7 +- .../project/ui/Bundle.properties | 10 + .../remote/ui/Bundle.properties | 6 +- .../DefaultIssueTestImpl.java | 13 + .../SonarLintEngineImplJavaPluginTest.java | 1 + ...narLintEngineImplJavascriptPluginTest.java | 1 + .../SonarLintEngineImplPhpPluginTest.java | 1 + .../SonarLintEngineImplTest.java | 1 + .../SonarLintEngineImplWebPluginTest.java | 1 + .../SonarLintEngineImplXmlPluginTest.java | 1 + .../SonarLintUtilsTest.java | 1 + .../SonarLintLookupMockedExtension.java | 3 +- 39 files changed, 2062 insertions(+), 174 deletions(-) create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java rename src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/{SonarLintConnectionConfiguration.java => configuration/SonarLintRemoteConnectionConfiguration.java} (70%) rename src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/{SonarLintConnectionConfigurationManagement.java => configuration/SonarLintRemoteConnectionConfigurationManagement.java} (75%) create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java rename src/test/java/com/github/philippefichet/sonarlint4netbeans/{ => junit/jupiter/extension}/SonarLintLookupMockedExtension.java (98%) diff --git a/README.adoc b/README.adoc index 12c1a9b..ae8273e 100644 --- a/README.adoc +++ b/README.adoc @@ -1,5 +1,7 @@ -:toc: +:toc: left :toclevels: 5 +:sectnums: 8 +:icons: font = sonarlint4netbeans diff --git a/pom.xml b/pom.xml index 2ebfb98..02d955f 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ org.apache.netbeans.utilities nbm-maven-plugin - 4.7 + 4.8 true Lesser GPL 2.1 @@ -254,7 +254,23 @@ org.sonarsource.sonarlint.core sonarlint-core - 8.11.0.56591 + 8.15.0.65216 + + + + org.jetbrains.kotlin + kotlin-stdlib + 1.8.20 + + + org.slf4j + slf4j-api + ${org.slf4j.version} + + + org.slf4j + slf4j-jdk14 + ${org.slf4j.version} org.sonarsource.javascript @@ -316,6 +332,11 @@ org-netbeans-modules-projectapi ${org.netbeans.version} + + org.netbeans.api + org-netbeans-modules-projectuiapi-base + ${org.netbeans.version} + org.netbeans.api org-netbeans-modules-projectuiapi @@ -411,6 +432,12 @@ org-netbeans-modules-keyring ${org.netbeans.version} + + + org.netbeans.api + org-netbeans-libs-git + ${org.netbeans.version} + org.junit.jupiter junit-jupiter-api @@ -447,12 +474,6 @@ 1.21 test - - org.slf4j - slf4j-api - ${org.slf4j.version} - test - org.slf4j slf4j-simple @@ -483,5 +504,7 @@ https://sonarcloud.io plain + + warn diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java index 01b0081..03eb668 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java @@ -41,6 +41,7 @@ public class SonarLintOptions { public FileObject getSonarLintDetailsStyle() throws IOException { if (stylesheet == null) { + // java:S2095 detected only in remote issue OutputStream createAndOpen = getFileSystem().getRoot().createAndOpen("sonar-rule-details-style.css"); byte[] byteArray = getPreferences().getByteArray("options.stylesheet", null); if (byteArray == null || byteArray.length == 0) { diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java index 456c47d..b1e52f8 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java @@ -47,7 +47,6 @@ public class SonarLintTaskScanner extends FileTaskScanner implements PropertyCha public SonarLintTaskScanner(String displayName, String description) { super(displayName, description, "Miscellaneous/SonarLint"); - } public static SonarLintTaskScanner create() { diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java index 0c1da9e..d019d6e 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java @@ -19,6 +19,10 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintRemoteEngine; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.wrapper.SonarLintIssueWrapperForServerIssue; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -65,6 +69,7 @@ import org.sonarsource.sonarlint.core.client.api.common.RuleDetails; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener; +import org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration; import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneAnalysisConfiguration; import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneRuleDetails; import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneRuleParam; @@ -72,7 +77,9 @@ import org.sonarsource.sonarlint.core.commons.RuleKey; import org.sonarsource.sonarlint.core.commons.RuleType; import org.sonarsource.sonarlint.core.commons.Version; +import org.sonarsource.sonarlint.core.commons.log.ClientLogOutput; import org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor; +import org.sonarsource.sonarlint.core.serverconnection.issues.ServerIssue; /** * @@ -243,38 +250,104 @@ public static String toURL(RuleDetails ruleDetails) } public static List analyze(FileObject fileObject, String contentToAnalyze) throws IOException { + // TODO scope remote = changement de moteur + FileObject configRoot = FileUtil.getConfigRoot(); + System.out.println("configRoot = " + configRoot); SonarLintEngine sonarLintEngine = Lookup.getDefault().lookup(SonarLintEngine.class); if (sonarLintEngine == null) { return Collections.emptyList(); } - SonarLintDataManager dataManager = Lookup.getDefault().lookup(SonarLintDataManager.class); - Project projectForRules = SonarLintDataManagerUtils.getProjectForAnalyse(dataManager, fileObject); - SonarLintOptions sonarlintOptions = Lookup.getDefault().lookup(SonarLintOptions.class); - boolean useTestRules = sonarlintOptions == null || sonarlintOptions.applyDifferentRulesOnTestFiles(); - - String sonarLintHome = System.getProperty("user.home") + File.separator + ".sonarlint4netbeans"; - List issues = new ArrayList<>(); - List excludedRules = new ArrayList<>(sonarLintEngine.getExcludedRules(projectForRules)); - List includedRules = new ArrayList<>(sonarLintEngine.getIncludedRules(projectForRules)); + File toFile = FileUtil.toFile(fileObject); if (toFile == null) { return Collections.emptyList(); } - Path path = toFile.toPath(); - List files = new ArrayList<>(); + SonarLintOptions sonarlintOptions = Lookup.getDefault().lookup(SonarLintOptions.class); + SonarLintDataManager dataManager = Lookup.getDefault().lookup(SonarLintDataManager.class); + boolean useTestRules = sonarlintOptions == null || sonarlintOptions.applyDifferentRulesOnTestFiles(); + Project project = dataManager.getProject(fileObject).orElse(SonarLintEngine.GLOBAL_SETTINGS_PROJECT); + Path path = project == null + ? toFile.toPath() + : FileUtil.toFile(project.getProjectDirectory()).toPath(); + List clientInputFiles = new ArrayList<>(); boolean applyTestRules = useTestRules && dataManager.isTest(toFile); - files.add(new FSClientInputFile( - contentToAnalyze == null ? new String(Files.readAllBytes(path)) : contentToAnalyze, - path.toAbsolutePath(), - path.toFile().getName(), + String relativizeToFile = path.relativize(toFile.toPath()).toString(); + clientInputFiles.add(new FSClientInputFile( + contentToAnalyze == null ? new String(Files.readAllBytes(toFile.toPath())) : contentToAnalyze, + toFile.toPath().toAbsolutePath(), + relativizeToFile, applyTestRules, FileEncodingQuery.getEncoding(fileObject)) ); + SonarLintProjectPreferenceScope preferencesScope = dataManager.getPreferencesScope(project); + String sonarLintHome = System.getProperty("user.home") + File.separator + ".sonarlint4netbeans"; + if (preferencesScope == SonarLintProjectPreferenceScope.REMOTE) { + SonarLintRemoteEngine remoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); + ConnectedAnalysisConfiguration build = ConnectedAnalysisConfiguration.builder() + .setProjectKey(sonarLintRemoteProjectConfiguration.getProjectKey()) + .addInputFiles(clientInputFiles) + .setBaseDir(new File(sonarLintHome).toPath()) + // TODO Remove dependency with sonarLintEngine + .putAllExtraProperties(getMergedExtraPropertiesAndReplaceVariables(sonarLintEngine, project)) + .build(); + List listener = new ArrayList<>(); + AnalysisResults remoteAnalyze = remoteEngine.analyze( + sonarLintRemoteProjectConfiguration, + build, + listener::add, + (String formattedMessage, ClientLogOutput.Level level) -> { + System.out.println(level + " | " + formattedMessage); + }, + new ClientProgressMonitor() { + @Override + public boolean isCanceled() { + return false; + } + + @Override + public void setMessage(String msg) { + LOG.info("ClientProgressMonitor.setMessage(\"" + msg + "\")"); + } + + @Override + public void setFraction(float fraction) { + LOG.info("ClientProgressMonitor.setFraction(" + fraction + ")"); + } + + @Override + public void setIndeterminate(boolean indeterminate) { + LOG.info("ClientProgressMonitor.setIndeterminate(" + indeterminate + ")"); + } + } + ); + + List serverIssues = remoteEngine.getServerIssues(sonarLintRemoteProjectConfiguration, relativizeToFile); + serverIssues.stream() + .map( + s -> + new SonarLintIssueWrapperForServerIssue( + clientInputFiles.get(0), + s, + sonarLintEngine.getRuleDetails(s.getRuleKey()) + ) + ) + .forEach(listener::add); + LOG.fine(() -> "Analyze (Remote) result for file \"" + fileObject.getPath() + "\" : " + remoteAnalyze); + + return listener; + } + + Project projectForRules = SonarLintDataManagerUtils.getProjectForAnalyse(dataManager, fileObject); + List issues = new ArrayList<>(); + List excludedRules = new ArrayList<>(sonarLintEngine.getExcludedRules(projectForRules)); + List includedRules = new ArrayList<>(sonarLintEngine.getIncludedRules(projectForRules)); + StandaloneAnalysisConfiguration standaloneAnalysisConfiguration = StandaloneAnalysisConfiguration.builder() .setBaseDir(new File(sonarLintHome).toPath()) - .addInputFiles(files) + .addInputFiles(clientInputFiles) .addExcludedRules(excludedRules) .addIncludedRules(includedRules) .addRuleParameters(sonarLintEngine.getRuleParameters(projectForRules)) @@ -466,6 +539,7 @@ public static AnalysisResults analyze( ClientInputFileListener clientInputFileInputStreamEvent, SonarLintAnalyzerCancelableTask sonarLintAnalyzerCancelableTask ) { + // TODO pas besoin du moteur ici tant que la séparation en fichier n'est pas fait SonarLintEngine sonarLintEngine = Lookup.getDefault().lookup(SonarLintEngine.class); if (sonarLintEngine == null) { return new AnalysisResults(); @@ -508,10 +582,8 @@ public static AnalysisResults analyze( projectForRules = SonarLintDataManagerUtils.getProjectForAnalyse(dataManager, FileUtil.toFileObject(projectFiles.get(0))); } } - String sonarLintHome = System.getProperty("user.home") + File.separator + ".sonarlint4netbeans"; - List excludedRules = new ArrayList<>(sonarLintEngine.getExcludedRules(projectForRules)); - List includedRules = new ArrayList<>(sonarLintEngine.getIncludedRules(projectForRules)); + List clientInputFiles = new ArrayList<>(); for (File file : files) { // Map file to implementation of ClientInputFile @@ -533,6 +605,48 @@ public static AnalysisResults analyze( LOG.warning("Error during getEncoding from \"" + file.getAbsolutePath() + "\": " + ex.getMessage()); } } + + SonarLintProjectPreferenceScope preferencesScope = dataManager.getPreferencesScope(project); + if (preferencesScope == SonarLintProjectPreferenceScope.REMOTE) { + SonarLintRemoteEngine remoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); + ConnectedAnalysisConfiguration build = ConnectedAnalysisConfiguration.builder() + .setProjectKey(sonarLintRemoteProjectConfiguration.getProjectKey()) + .addInputFiles(clientInputFiles) + // TODO supprimer le lien avec sonarLintEngine + .putAllExtraProperties(getMergedExtraPropertiesAndReplaceVariables(sonarLintEngine, project)) + .build(); + return remoteEngine.analyze( + sonarLintRemoteProjectConfiguration, + build, + listener, + null, + new ClientProgressMonitor() { + @Override + public boolean isCanceled() { + return sonarLintAnalyzerCancelableTask != null && sonarLintAnalyzerCancelableTask.isCanceled(); + } + + @Override + public void setMessage(String msg) { + LOG.info("ClientProgressMonitor.setMessage(\"" + msg + "\")"); + } + + @Override + public void setFraction(float fraction) { + LOG.info("ClientProgressMonitor.setFraction(" + fraction + ")"); + } + + @Override + public void setIndeterminate(boolean indeterminate) { + LOG.info("ClientProgressMonitor.setIndeterminate(" + indeterminate + ")"); + } + } + ); + } + + List excludedRules = new ArrayList<>(sonarLintEngine.getExcludedRules(projectForRules)); + List includedRules = new ArrayList<>(sonarLintEngine.getIncludedRules(projectForRules)); StandaloneAnalysisConfiguration standaloneAnalysisConfiguration = StandaloneAnalysisConfiguration.builder() @@ -745,5 +859,4 @@ public static void tryToSearchDefaultNodeJS(Supplier pathEnvironmentVari Logger.getLogger(SonarLintUtils.class.getName()).log(Level.INFO, "Cannot use default installation of Node.js: " + ex.getMessage()); } } - } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java index f4c1d50..fa45c97 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java @@ -120,6 +120,11 @@ public void propertyChange(PropertyChangeEvent evt) { endLineOffset = 0; } + if (startLineOffset == null || endLineOffset == null) { + startLineOffset = 0; + endLineOffset = 0; + } + int nbStartLineOffset = NbDocument.findLineOffset(editorCookie.getDocument(), startLine - 1); int startOffset = nbStartLineOffset + startLineOffset; int nbEndLineOffset = NbDocument.findLineOffset(editorCookie.getDocument(), endLine - 1); diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java index 294a7d1..139c778 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java @@ -25,5 +25,7 @@ */ public enum SonarLintProjectPreferenceScope { PROJECT, - GLOBAL; + GLOBAL, + REMOTE, + ; } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.form b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.form index c3cd8eb..8415dba 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.form +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.form @@ -27,31 +27,205 @@ - - - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java index 11119ad..3ae45a8 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java @@ -21,9 +21,16 @@ import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManager; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintRemoteEngine; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfigurationManagement; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.synchronization.TaskWrapper; import java.awt.event.ActionEvent; +import java.util.Optional; import org.netbeans.api.project.Project; import org.netbeans.spi.project.ui.support.ProjectCustomizer; +import org.openide.awt.Mnemonics; +import org.openide.util.Lookup; /** * Panel to choose project scope for rule settings @@ -34,6 +41,7 @@ }) public class SonarLintProjectCustomizerPanel extends javax.swing.JPanel { private SonarLintProjectPreferenceScope scope = SonarLintProjectPreferenceScope.GLOBAL; + private final Project project; /** * Creates new form SonarLintProjectCustomizerPanel @@ -43,19 +51,44 @@ public class SonarLintProjectCustomizerPanel extends javax.swing.JPanel { */ public SonarLintProjectCustomizerPanel(SonarLintDataManager sonarLintDataManager, Project project, ProjectCustomizer.Category category) { initComponents(); + this.project = project; SonarLintProjectPreferenceScope actualScope = sonarLintDataManager.getPreferencesScope(project); if (actualScope == SonarLintProjectPreferenceScope.PROJECT) { scopeProjectRadioButton.setSelected(true); + scope = SonarLintProjectPreferenceScope.PROJECT; } - category.setOkButtonListener((ActionEvent actionEvent) -> - sonarLintDataManager.setPreferencesScope(project, scope) - ); + if (actualScope == SonarLintProjectPreferenceScope.GLOBAL) { + scopeGlobalRadioButton.setSelected(true); + } + if (actualScope == SonarLintProjectPreferenceScope.REMOTE) { + scope = SonarLintProjectPreferenceScope.REMOTE; + scopeRemoteRadioButton.setSelected(true); + scopeRemoteRadioButtonActionPerformed(null); + SonarLintRemoteProjectConfiguration projectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); + connectionsComboBox.setSelectedItem(projectConfiguration.getConnectionId()); + projectKeyTextField.setText(projectConfiguration.getProjectKey()); + organisationTextField.setText(projectConfiguration.getOrganization()); + } + category.setOkButtonListener((ActionEvent actionEvent) -> { + sonarLintDataManager.setPreferencesScope(project, scope); + if (scope == SonarLintProjectPreferenceScope.REMOTE) { + SonarLintRemoteProjectConfiguration.save( + project, + (String)connectionsComboBox.getSelectedItem(), + projectKeyTextField.getText(), + organisationTextField.getText() + ); + } + }); scopeGlobalRadioButton.addActionListener((ActionEvent actionEvent) -> scope = SonarLintProjectPreferenceScope.GLOBAL ); scopeProjectRadioButton.addActionListener((ActionEvent actionEvent) -> scope = SonarLintProjectPreferenceScope.PROJECT ); + scopeRemoteRadioButton.addActionListener((ActionEvent actionEvent) -> + scope = SonarLintProjectPreferenceScope.REMOTE + ); } /** @@ -69,30 +102,217 @@ private void initComponents() { scopeRadioButtonGroup = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); + jPanel3 = new javax.swing.JPanel(); scopeGlobalRadioButton = new javax.swing.JRadioButton(); scopeProjectRadioButton = new javax.swing.JRadioButton(); + scopeRemoteRadioButton = new javax.swing.JRadioButton(); + remoteConfiguration = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); + warningLabel = new javax.swing.JLabel(); + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + connectionsLabel = new javax.swing.JLabel(); + connectionsComboBox = new javax.swing.JComboBox<>(); + projectKeyLabel = new javax.swing.JLabel(); + projectKeyTextField = new javax.swing.JTextField(); + organisationLabel = new javax.swing.JLabel(); + organisationTextField = new javax.swing.JTextField(); + jPanel6 = new javax.swing.JPanel(); + syncProject = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); - jPanel1.setLayout(new javax.swing.BoxLayout(jPanel1, javax.swing.BoxLayout.PAGE_AXIS)); + jPanel1.setLayout(new java.awt.BorderLayout()); + + jPanel3.setLayout(new javax.swing.BoxLayout(jPanel3, javax.swing.BoxLayout.PAGE_AXIS)); scopeRadioButtonGroup.add(scopeGlobalRadioButton); scopeGlobalRadioButton.setSelected(true); org.openide.awt.Mnemonics.setLocalizedText(scopeGlobalRadioButton, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.scopeGlobalRadioButton.text")); // NOI18N - jPanel1.add(scopeGlobalRadioButton); + scopeGlobalRadioButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); + jPanel3.add(scopeGlobalRadioButton); scopeRadioButtonGroup.add(scopeProjectRadioButton); org.openide.awt.Mnemonics.setLocalizedText(scopeProjectRadioButton, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.scopeProjectRadioButton.text")); // NOI18N - jPanel1.add(scopeProjectRadioButton); + jPanel3.add(scopeProjectRadioButton); + + scopeRadioButtonGroup.add(scopeRemoteRadioButton); + org.openide.awt.Mnemonics.setLocalizedText(scopeRemoteRadioButton, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.scopeRemoteRadioButton.text")); // NOI18N + scopeRemoteRadioButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + scopeRemoteRadioButtonActionPerformed(evt); + } + }); + jPanel3.add(scopeRemoteRadioButton); + + jPanel1.add(jPanel3, java.awt.BorderLayout.NORTH); + + remoteConfiguration.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.remoteConfiguration.border.title"))); // NOI18N + remoteConfiguration.setEnabled(false); + remoteConfiguration.setLayout(new java.awt.BorderLayout()); + + jPanel4.setLayout(new javax.swing.BoxLayout(jPanel4, javax.swing.BoxLayout.LINE_AXIS)); + + org.openide.awt.Mnemonics.setLocalizedText(warningLabel, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.warningLabel.text")); // NOI18N + jPanel4.add(warningLabel); + + remoteConfiguration.add(jPanel4, java.awt.BorderLayout.NORTH); + + jPanel5.setLayout(new java.awt.BorderLayout()); + + jPanel2.setLayout(new java.awt.GridLayout(4, 0)); + + org.openide.awt.Mnemonics.setLocalizedText(connectionsLabel, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.connectionsLabel.text")); // NOI18N + jPanel2.add(connectionsLabel); + + jPanel2.add(connectionsComboBox); + + org.openide.awt.Mnemonics.setLocalizedText(projectKeyLabel, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.projectKeyLabel.text")); // NOI18N + jPanel2.add(projectKeyLabel); + + projectKeyTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.projectKeyTextField.text")); // NOI18N + jPanel2.add(projectKeyTextField); + + org.openide.awt.Mnemonics.setLocalizedText(organisationLabel, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.organisationLabel.text")); // NOI18N + jPanel2.add(organisationLabel); + + organisationTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.organisationTextField.text")); // NOI18N + jPanel2.add(organisationTextField); + + jPanel5.add(jPanel2, java.awt.BorderLayout.NORTH); + + org.openide.awt.Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.text")); // NOI18N + syncProject.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + syncProjectActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addContainerGap(150, Short.MAX_VALUE) + .addComponent(syncProject) + .addContainerGap(150, Short.MAX_VALUE)) + ); + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGap(5, 5, 5) + .addComponent(syncProject) + .addGap(50, 50, 50)) + ); + + jPanel5.add(jPanel6, java.awt.BorderLayout.CENTER); + + remoteConfiguration.add(jPanel5, java.awt.BorderLayout.CENTER); + + jPanel1.add(remoteConfiguration, java.awt.BorderLayout.CENTER); add(jPanel1, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents + private void scopeRemoteRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_scopeRemoteRadioButtonActionPerformed + boolean enabledRemoteConfiguration = scopeRemoteRadioButton.isSelected(); + remoteConfiguration.setEnabled(enabledRemoteConfiguration); + connectionsLabel.setEnabled(enabledRemoteConfiguration); + connectionsComboBox.setEnabled(enabledRemoteConfiguration); + projectKeyLabel.setEnabled(enabledRemoteConfiguration); + projectKeyTextField.setEnabled(enabledRemoteConfiguration); + organisationLabel.setEnabled(enabledRemoteConfiguration); + organisationTextField.setEnabled(enabledRemoteConfiguration); + syncProject.setEnabled(enabledRemoteConfiguration); + if (enabledRemoteConfiguration) { + connectionsComboBox.removeAllItems(); + SonarLintRemoteConnectionConfigurationManagement sonarLintRemoteConnectionConfigurationManagement = Lookup.getDefault().lookup(SonarLintRemoteConnectionConfigurationManagement.class); + sonarLintRemoteConnectionConfigurationManagement.getAllSonarLintConnectionConfigurations() + .forEach(c -> connectionsComboBox.addItem(c.getConnectionId())); + } + }//GEN-LAST:event_scopeRemoteRadioButtonActionPerformed + + private void syncProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_syncProjectActionPerformed + String sonarLintRemoteConnectionId = (String)connectionsComboBox.getSelectedItem(); + if (sonarLintRemoteConnectionId != null) { + SonarLintRemoteEngine sonarLintRemoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); + SonarLintRemoteProjectConfiguration projectConfiguration = SonarLintRemoteProjectConfiguration.fromProject( + project, + sonarLintRemoteConnectionId, + projectKeyTextField.getText(), + organisationTextField.getText() + ); + Optional launchedResyncTask = sonarLintRemoteEngine.getLaunchedResyncTask(projectConfiguration); + if (launchedResyncTask.isPresent() && launchedResyncTask.get().getTask().isFinished() == false) { + launchedResyncTask.get().getTask().addTaskListener( + task -> + Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.text")) + ); + launchedResyncTask.get().getSonarLintRemoteSynchronizationTask().cancel(); + } else { + TaskWrapper launchResyncTask = sonarLintRemoteEngine.launchResyncTask(projectConfiguration); + launchResyncTask.getTask().addTaskListener( + task -> + Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.text")) + ); + Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.textCancel")); // NOI18N + } +// +// Cancellable cancellable = currentRemoteSyncCancellable.get(); +// if (cancellable != null) { +// cancellable.cancel(); +// } +// if (currentRemoteSync != null && currentRemoteSync.isAlive()) { +// currentRemoteSync.interrupt(); +// org.openide.awt.Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.text")); // NOI18N +// } else { +// currentRemoteSync = new Thread(() -> { +// currentRemoteSyncCancellable.set( +// sonarLintRemoteEngine.sync( +// projectConfiguration, +// (Status status, String message, int progress) -> { +// SwingUtilities.invokeLater(() -> { +// progressSyncProject.setString(message); +// progressSyncProject.setIndeterminate(progress < 0); +// if (progress >= 0) { +// progressSyncProject.setValue(progress); +// } +// if (status == Status.FINISH) { +// org.openide.awt.Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.text")); // NOI18N +// +// } +// }); +// } +// ) +// ); +// currentRemoteSyncCancellable.get().run(); +// }); +// currentRemoteSync.start(); +// org.openide.awt.Mnemonics.setLocalizedText(syncProject, org.openide.util.NbBundle.getMessage(SonarLintProjectCustomizerPanel.class, "SonarLintProjectCustomizerPanel.syncProject.textCancel")); // NOI18N +// } + } + }//GEN-LAST:event_syncProjectActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JComboBox connectionsComboBox; + private javax.swing.JLabel connectionsLabel; private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JLabel organisationLabel; + private javax.swing.JTextField organisationTextField; + private javax.swing.JLabel projectKeyLabel; + private javax.swing.JTextField projectKeyTextField; + private javax.swing.JPanel remoteConfiguration; private javax.swing.JRadioButton scopeGlobalRadioButton; private javax.swing.JRadioButton scopeProjectRadioButton; private javax.swing.ButtonGroup scopeRadioButtonGroup; + private javax.swing.JRadioButton scopeRemoteRadioButton; + private javax.swing.JButton syncProject; + private javax.swing.JLabel warningLabel; // End of variables declaration//GEN-END:variables } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java new file mode 100644 index 0000000..2349f2e --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java @@ -0,0 +1,262 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote; + +import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManager; +import com.github.philippefichet.sonarlint4netbeans.SonarLintEngine; +import com.github.philippefichet.sonarlint4netbeans.SonarLintUtils; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.synchronization.SonarLintRemoteSynchronizationTask; +import com.github.philippefichet.sonarlint4netbeans.remote.synchronization.TaskWrapper; +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.Clock; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.prefs.Preferences; +import org.netbeans.api.project.Project; +import org.openide.util.Lookup; +import org.openide.util.RequestProcessor; +import org.openide.util.Task; +import org.openide.util.lookup.ServiceProvider; +import org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl; +import org.sonarsource.sonarlint.core.analysis.api.AnalysisResults; +import org.sonarsource.sonarlint.core.client.api.common.AbstractGlobalConfiguration; +import org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener; +import org.sonarsource.sonarlint.core.client.api.connected.ConnectedAnalysisConfiguration; +import org.sonarsource.sonarlint.core.client.api.connected.ConnectedGlobalConfiguration; +import org.sonarsource.sonarlint.core.client.api.connected.ProjectBranches; +import org.sonarsource.sonarlint.core.commons.Language; +import org.sonarsource.sonarlint.core.commons.Version; +import org.sonarsource.sonarlint.core.commons.log.ClientLogOutput; +import org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor; +import org.sonarsource.sonarlint.core.serverconnection.ProjectBinding; +import org.sonarsource.sonarlint.core.serverconnection.issues.ServerIssue; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@ServiceProvider(service = SonarLintRemoteEngine.class) +public final class SonarLintRemoteEngine { + + private static final RequestProcessor RP = new RequestProcessor(SonarLintRemoteEngine.class); + private static final Map ALL_CURRENT_SYNC_TASKS = Collections.synchronizedMap(new HashMap<>()); + private static final Map LAST_SYNC = Collections.synchronizedMap(new HashMap<>()); + private static final String PREFIX_RUNTIME_PREFERENCE = "runtime."; + private static final String RUNTIME_NODE_JS_PATH_PREFERENCE = "nodejs.path"; + private static final String RUNTIME_NODE_JS_VERSION_PREFERENCE = "nodejs.version"; + private final Clock clock = Clock.systemUTC(); + private final Lookup lookup = Lookup.getDefault(); + + private final Map connectedSonarLintEngineImpls = Collections.synchronizedMap(new HashMap<>()); + + /** + * Default constructor for Lookup + */ + public SonarLintRemoteEngine() { + } + + private String toKey(SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration) { + return sonarLintRemoteProjectConfiguration.getProjectKey() + "-" + + sonarLintRemoteProjectConfiguration.getOrganization() + "-" + + sonarLintRemoteProjectConfiguration.getConnectionId() + "-" + + sonarLintRemoteProjectConfiguration.getProjectActiveBranch(); + } + + public Optional getLaunchedResyncTask( + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration + ) { + String key = toKey(sonarLintRemoteProjectConfiguration); + TaskWrapper currentTask = ALL_CURRENT_SYNC_TASKS.get(key); + return Optional.ofNullable(currentTask); + } + + public TaskWrapper launchResyncTask( + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration + ) { + String key = sonarLintRemoteProjectConfiguration.getProjectKey() + "-" + + sonarLintRemoteProjectConfiguration.getOrganization() + "-" + + sonarLintRemoteProjectConfiguration.getConnectionId() + "-" + + sonarLintRemoteProjectConfiguration.getProjectActiveBranch(); + TaskWrapper currentTask = ALL_CURRENT_SYNC_TASKS.get(key); + + if (currentTask != null && !currentTask.getTask().isFinished()) { + return currentTask; + } + SonarLintRemoteSynchronizationTask sync = createSyncTask( + sonarLintRemoteProjectConfiguration, + EnumSet.of(SonarLintRemoteSynchronizationTask.SyncPolicies.DOWNLOAD_ALL_SERVER_ISSUES, + SonarLintRemoteSynchronizationTask.SyncPolicies.UPDATE_PROJECT, + SonarLintRemoteSynchronizationTask.SyncPolicies.SYNC + ) + ); + RequestProcessor.Task create = RP.post(sync); + create.addTaskListener((Task task) -> { + ALL_CURRENT_SYNC_TASKS.remove(key); + LAST_SYNC.put(key, clock.millis()); + }); + TaskWrapper taskWrapper = new TaskWrapper(create, sync); + ALL_CURRENT_SYNC_TASKS.put(key, taskWrapper); + return taskWrapper; + } + + protected SonarLintRemoteSynchronizationTask createSyncTask( + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration, + EnumSet enumSet + ) { + return new SonarLintRemoteSynchronizationTask( + sonarLintRemoteProjectConfiguration, + () -> getConnectedSonarLintEngineImpl(sonarLintRemoteProjectConfiguration), + enumSet + ); + } + + private ConnectedSonarLintEngineImpl getConnectedSonarLintEngineImpl(SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration) + { + String sonarLintHome = System.getProperty("user.home") + File.separator + ".sonarlint4netbeans"; + return connectedSonarLintEngineImpls.computeIfAbsent( + sonarLintRemoteProjectConfiguration.getConnectionId(), + c -> + new ConnectedSonarLintEngineImpl( + createBuilder() + .setConnectionId(c) + .setStorageRoot(Paths.get(sonarLintHome, "storage")) + .setWorkDir(Paths.get(sonarLintHome, "work")) + .addEnabledLanguages(Language.values()) + .build() + ) + ); + } + + private ConnectedGlobalConfiguration.Builder createBuilder() + { + ConnectedGlobalConfiguration.Builder builder = ConnectedGlobalConfiguration.sonarCloudBuilder(); + // TODO à vérifier + Optional nodeJSPathOptional = getNodeJSPath(); + Optional nodeJSVersionOptional = getNodeJSVersion(); + if (nodeJSPathOptional.isPresent() && nodeJSVersionOptional.isPresent()) { + String nodeJSPath = nodeJSPathOptional.get(); + Version nodeJSVersion = nodeJSVersionOptional.get(); + Path nodeJS = Paths.get(nodeJSPath); + builder.setNodeJs(nodeJS, nodeJSVersion); + } else { + tryToSetDefaultNodeJS(builder); + } + return builder; + } + + public AnalysisResults analyze( + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration, + ConnectedAnalysisConfiguration configuration, + IssueListener issueListener, + ClientLogOutput logOutput, + ClientProgressMonitor monitor + ) { + waitingSync(sonarLintRemoteProjectConfiguration); + ConnectedSonarLintEngineImpl connectedSonarLintEngineImpl = getConnectedSonarLintEngineImpl(sonarLintRemoteProjectConfiguration); + return connectedSonarLintEngineImpl.analyze( + configuration, + issueListener, + logOutput, + monitor + ); + } + + private void waitingSync(SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration) + { + Long get = LAST_SYNC.get(toKey(sonarLintRemoteProjectConfiguration)); + if (get == null) { + launchResyncTask(sonarLintRemoteProjectConfiguration) + .getTask() + .waitFinished(); + } + } + + public List getServerIssues( + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration, + String relativizePathToAnalyze + ) + { + waitingSync(sonarLintRemoteProjectConfiguration); + ProjectBinding projectBinding = new ProjectBinding( + sonarLintRemoteProjectConfiguration.getProjectKey(), + "", + "" + ); + + ConnectedSonarLintEngineImpl connectedSonarLintEngineImpl = getConnectedSonarLintEngineImpl(sonarLintRemoteProjectConfiguration); +// connectedSonarLintEngineImpl.getActiveRuleDetails(endpoint, client, relativizePathToAnalyze, relativizePathToAnalyze); +// connectedSonarLintEngineImpl.downloadAllServerIssuesForFile(endpoint, client, projectBinding, relativizePathToAnalyze, relativizePathToAnalyze, monitor);AllServerIssues(endpoint, client, relativizePathToAnalyze, relativizePathToAnalyze, monitor); + return connectedSonarLintEngineImpl.getServerIssues( + projectBinding, + findBestBranch(connectedSonarLintEngineImpl, sonarLintRemoteProjectConfiguration), + relativizePathToAnalyze + ); + } + + private String findBestBranch(ConnectedSonarLintEngineImpl connectedSonarLintEngineImpl, SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration) { + ProjectBranches serverBranches = connectedSonarLintEngineImpl.getServerBranches(sonarLintRemoteProjectConfiguration.getProjectKey()); + if (sonarLintRemoteProjectConfiguration.getProjectActiveBranch().isPresent()) { + String branchProject = sonarLintRemoteProjectConfiguration.getProjectActiveBranch().get(); + return serverBranches.getBranchNames() + .stream() + .filter(b -> b.equals(branchProject)) + .findFirst().orElseGet(serverBranches::getMainBranchName); + } + return serverBranches.getMainBranchName(); + } + + /************************/ + private SonarLintDataManager getSonarLintDataManager() + { + return lookup.lookup(SonarLintDataManager.class); + } + + public Preferences getPreferences(Project project) { + SonarLintDataManager dataManager = getSonarLintDataManager(); + if (project == SonarLintEngine.GLOBAL_SETTINGS_PROJECT) { + return dataManager.getGlobalSettingsPreferences(); + } else { + return dataManager.getPreferences(project); + } + } + + private void tryToSetDefaultNodeJS(AbstractGlobalConfiguration.AbstractBuilder configBuilder) { + SonarLintUtils.tryToSearchDefaultNodeJS( + () -> SonarLintUtils.searchPathEnvVar().orElse(""), + configBuilder::setNodeJs + ); + } + + public Optional getNodeJSPath() { + return Optional.ofNullable(getPreferences(SonarLintEngine.GLOBAL_SETTINGS_PROJECT).get(PREFIX_RUNTIME_PREFERENCE + RUNTIME_NODE_JS_PATH_PREFERENCE, null)); + } + + public Optional getNodeJSVersion() { + return Optional.ofNullable( + getPreferences(SonarLintEngine.GLOBAL_SETTINGS_PROJECT).get(PREFIX_RUNTIME_PREFERENCE + RUNTIME_NODE_JS_VERSION_PREFERENCE, null) + ).map(Version::create); + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java new file mode 100644 index 0000000..07cfaea --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote; + +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.wrapper.SonarLintRemoteHttpClient; +import java.util.function.Consumer; +import org.sonarsource.sonarlint.core.serverapi.EndpointParams; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteEngineUtils { + public static SonarLintRemoteHttpClient createSonarLintRemoteHttpClient( + String authToken, + SonarLintRemoteConnectionConfiguration sonarLintRemoteConnectionConfiguration, + Consumer responseReadByteConsumer + ) { + return new SonarLintRemoteHttpClient( + authToken, + sonarLintRemoteConnectionConfiguration.isIsSonarCloud() + ? SonarLintRemoteHttpClient.Authentification.BEARER + : SonarLintRemoteHttpClient.Authentification.BASIC, + responseReadByteConsumer + ); + } + + public static EndpointParams createEndpointParams(SonarLintRemoteConnectionConfiguration sonarLintRemoteConnectionConfiguration, String organization) { + return new EndpointParams( + sonarLintRemoteConnectionConfiguration.getBaseURL(), + sonarLintRemoteConnectionConfiguration.isIsSonarCloud(), + organization + ); + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java similarity index 70% rename from src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java rename to src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java index 578f625..5528266 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfiguration.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java @@ -16,35 +16,27 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.github.philippefichet.sonarlint4netbeans.remote; +package com.github.philippefichet.sonarlint4netbeans.remote.configuration; /** * * @author FICHET Philippe <philippe.fichet@laposte.net> */ -public class SonarLintConnectionConfiguration { +public class SonarLintRemoteConnectionConfiguration { private final String connectionId; - private final String projectKey; private final String baseURL; private final boolean isSonarCloud; - private final String organization; - public SonarLintConnectionConfiguration(String connectionId, String projectKey, String baseURL, boolean isSonarCloud, String organization) { + public SonarLintRemoteConnectionConfiguration(String connectionId, String baseURL, boolean isSonarCloud) { this.connectionId = connectionId; - this.projectKey = projectKey; this.baseURL = baseURL; this.isSonarCloud = isSonarCloud; - this.organization = organization; } public String getConnectionId() { return connectionId; } - public String getProjectKey() { - return projectKey; - } - public String getBaseURL() { return baseURL; } @@ -53,8 +45,4 @@ public boolean isIsSonarCloud() { return isSonarCloud; } - public String getOrganization() { - return organization; - } - } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java similarity index 75% rename from src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java rename to src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java index ad144bd..f07f642 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintConnectionConfigurationManagement.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.github.philippefichet.sonarlint4netbeans.remote; +package com.github.philippefichet.sonarlint4netbeans.remote.configuration; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; @@ -33,15 +33,15 @@ * * @author FICHET Philippe <philippe.fichet@laposte.net> */ -@ServiceProvider(service = SonarLintConnectionConfigurationManagement.class) -public class SonarLintConnectionConfigurationManagement { +@ServiceProvider(service = SonarLintRemoteConnectionConfigurationManagement.class) +public class SonarLintRemoteConnectionConfigurationManagement { private final Gson gson = new Gson(); /** * Default constructor for Lookup */ - public SonarLintConnectionConfigurationManagement() + public SonarLintRemoteConnectionConfigurationManagement() { /* Project project = Lookup.getDefault().lookup(Project.class); @@ -58,13 +58,13 @@ public SonarLintConnectionConfigurationManagement() public Optional getAuthTokenFromConnectionId(String connectionId) { return Optional.ofNullable( - Keyring.read(SonarLintConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId) + Keyring.read(SonarLintRemoteConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId) ).map(String::new); } public void saveAuthTokenFromConnectionId(String connectionId, String token) { Keyring.save( - SonarLintConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId, + SonarLintRemoteConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId, token.toCharArray(), "Auth token for SonarLint Remote connectionId \"" + connectionId + "\"" ); @@ -72,18 +72,18 @@ public void saveAuthTokenFromConnectionId(String connectionId, String token) { public void deleteAuthTokenFromConnectionId(String connectionId) { Keyring.delete( - SonarLintConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId + SonarLintRemoteConnectionConfiguration.class.getCanonicalName() + ".auth-token." + connectionId ); } - public Optional getSonarLintConnectionConfigurationFromConnectionId(String connectionId) { + public Optional getSonarLintConnectionConfigurationFromConnectionId(String connectionId) { return getAllSonarLintConnectionConfigurations().stream() .filter(c -> c.getConnectionId().equals(connectionId)) .findFirst(); } public void deleteSonarLintConnectionConfigurationFromConnectionId(String connectionId) { - Preferences preferences = NbPreferences.forModule(SonarLintConnectionConfiguration.class); + Preferences preferences = NbPreferences.forModule(SonarLintRemoteConnectionConfiguration.class); preferences.put( "connections", gson.toJson( @@ -95,16 +95,16 @@ public void deleteSonarLintConnectionConfigurationFromConnectionId(String connec ); } - public List getAllSonarLintConnectionConfigurations() { - Preferences preferences = NbPreferences.forModule(SonarLintConnectionConfiguration.class); + public List getAllSonarLintConnectionConfigurations() { + Preferences preferences = NbPreferences.forModule(SonarLintRemoteConnectionConfiguration.class); return gson.fromJson( preferences.get("connections", "[]"), - new TypeToken>() {}.getType() + new TypeToken>() {}.getType() ); } - public void saveSonarLintConnectionConfiguration(SonarLintConnectionConfiguration sonarLintConnectionConfiguration) { - Preferences preferences = NbPreferences.forModule(SonarLintConnectionConfiguration.class); + public void saveSonarLintConnectionConfiguration(SonarLintRemoteConnectionConfiguration sonarLintConnectionConfiguration) { + Preferences preferences = NbPreferences.forModule(SonarLintRemoteConnectionConfiguration.class); preferences.put( "connections", gson.toJson( diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java new file mode 100644 index 0000000..ea0ad88 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.configuration; + +import java.io.File; +import java.util.Map; +import java.util.Optional; +import java.util.prefs.Preferences; +import org.netbeans.api.project.Project; +import org.netbeans.api.project.ProjectUtils; +import org.netbeans.libs.git.GitBranch; +import org.netbeans.libs.git.GitException; +import org.netbeans.libs.git.GitRepository; +import org.netbeans.libs.git.progress.ProgressMonitor; +import org.openide.filesystems.FileUtil; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteProjectConfiguration { + private static final String PROP_CONNECTION_ID = "sonarlint-remote-connection-id"; + private static final String PROP_PROJECT_KEY = "sonarlint-remote-project-key"; + private static final String PROP_ORGANIZATION = "sonarlint-remote-oorganization"; + private final Project project; + private final String connectionId; + private final String projectKey; + private final String organization; + private final String activeBranch; + + public SonarLintRemoteProjectConfiguration(Project project, String connectionId, String projectKey, String organization, String activeBranch) { + this.project = project; + this.connectionId = connectionId; + this.projectKey = projectKey; + this.organization = organization; + this.activeBranch = activeBranch; + } + + public static SonarLintRemoteProjectConfiguration fromProject(Project project) { + Preferences preferences = ProjectUtils.getPreferences(project, SonarLintRemoteProjectConfiguration.class, true); + return new SonarLintRemoteProjectConfiguration( + project, + preferences.get(PROP_CONNECTION_ID, null), + preferences.get(PROP_PROJECT_KEY, null), + preferences.get(PROP_ORGANIZATION, null), + null + ); + } + + public static SonarLintRemoteProjectConfiguration fromProject(Project project, String connectionId, String projectKey, String organization) { + File projectDir = FileUtil.toFile(project.getProjectDirectory()); + GitRepository instance = GitRepository.getInstance(projectDir); + Map branches = null; + try { + branches = instance.createClient().getBranches(false, new ProgressMonitor.DefaultProgressMonitor()); + } catch (GitException ex) { + } + return new SonarLintRemoteProjectConfiguration( + project, + connectionId, + projectKey, + organization, + branches == null ? null : branches.values().iterator().next().getName() + ); + } + + public static void save(Project project, String sonarLintRemoteConnectionId, String projectKey, String organization) { + Preferences preferences = ProjectUtils.getPreferences(project, SonarLintRemoteProjectConfiguration.class, true); + preferences.put(PROP_CONNECTION_ID, sonarLintRemoteConnectionId); + preferences.put(PROP_PROJECT_KEY, projectKey); + preferences.put(PROP_ORGANIZATION, organization); + } + + public Optional getProjectActiveBranch() { + if (activeBranch != null) { + return Optional.of(activeBranch); + } + File projectDir = FileUtil.toFile(project.getProjectDirectory()); + + GitRepository instance = GitRepository.getInstance(projectDir); + Map branches = null; + try { + branches = instance.createClient().getBranches(false, new ProgressMonitor.DefaultProgressMonitor()); + } catch (GitException ex) { + // Exceptions.printStackTrace(ex); + } + if (branches != null) { + return Optional.of(branches.values().iterator().next().getName()); + } + return Optional.empty(); + } + + public String getConnectionId() { + return connectionId; + } + + public String getProjectKey() { + return projectKey; + } + + public String getOrganization() { + return organization; + } + + public Project getProject() { + return project; + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java new file mode 100644 index 0000000..8443dc2 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.listener; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@FunctionalInterface +public interface SonarLintRemoteEnginSyncListener { + public enum Status { + NOT_STARTED, + RUNNING, + FINISH, + CANCELLED, + } + void consume(Status status, String message); +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java new file mode 100644 index 0000000..32d185d --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.listener; + +import org.netbeans.api.progress.ProgressHandle; +import org.openide.util.Cancellable; +import org.openide.util.Exceptions; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteSyncListenerProgressHandle implements SonarLintRemoteEnginSyncListener { + private final ProgressHandle handle; + + public SonarLintRemoteSyncListenerProgressHandle(String projectKey, Cancellable cancellable) { + handle = ProgressHandle.createHandle("SonarLint Sync (init)", cancellable); + handle.setDisplayName("SonarLint " + projectKey); + handle.start(); + handle.switchToIndeterminate(); + handle.progress("Initialization"); + } + + @Override + public void consume(Status status, String message) { + if(status == Status.FINISH) { + handle.close(); + return; + } + + if(status == Status.CANCELLED) { + handle.setDisplayName("SonarLint Sync (canceled)"); + handle.progress("Canceled"); + handle.close(); + return; + } + + handle.progress(message); + try { + Thread.sleep(1); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } + } + +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java new file mode 100644 index 0000000..5537c87 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.project; + +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintRemoteEngine; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.synchronization.TaskWrapper; +import java.util.Optional; +import org.netbeans.api.project.Project; +import org.netbeans.spi.project.ProjectServiceProvider; +import org.netbeans.spi.project.ui.ProjectOpenedHook; +import org.openide.util.Lookup; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@ProjectServiceProvider( + service=ProjectOpenedHook.class, + projectType = { + "org-netbeans-modules-ant-freeform", + "org-netbeans-modules-apisupport-project", + "org-netbeans-modules-j2ee-clientproject", + "org-netbeans-modules-j2ee-earproject", + "org-netbeans-modules-j2ee-ejbjarproject", + "org-netbeans-modules-java-j2seproject", + "org-netbeans-modules-java-j2semodule", + "org-netbeans-modules-maven", + "org-netbeans-modules-gradle", + "org-netbeans-modules-cnd-makeproject", + "org-netbeans-modules-cpplite-project-CPPLiteProject", + "org-netbeans-modules-php-project", + "org-netbeans-modules-web-project", + "org-netbeans-modules-web-clientproject", + } +) +public class SonarLintSyncTaskProjectOpenedHook extends ProjectOpenedHook { + private Project project; + + public SonarLintSyncTaskProjectOpenedHook(Project project) { + this.project = project; + } + + @Override + protected void projectOpened() { + SonarLintRemoteProjectConfiguration projectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); + if (projectConfiguration.getConnectionId() != null + && projectConfiguration.getOrganization() != null + && projectConfiguration.getProjectKey() != null) { + + SonarLintRemoteEngine sonarLintRemoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); + sonarLintRemoteEngine.launchResyncTask(projectConfiguration); + } + } + + @Override + protected void projectClosed() { + SonarLintRemoteProjectConfiguration projectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); + SonarLintRemoteEngine sonarLintRemoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); + Optional launchedResyncTask = sonarLintRemoteEngine.getLaunchedResyncTask(projectConfiguration); + sonarLintRemoteEngine.launchResyncTask(projectConfiguration); + if (launchedResyncTask.isPresent() && launchedResyncTask.get().getTask().isFinished() == false) { + launchedResyncTask.get().getSonarLintRemoteSynchronizationTask().cancel(); + } + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java new file mode 100644 index 0000000..73acf06 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.synchronization; + +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfigurationManagement; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.listener.SonarLintRemoteEnginSyncListener; +import com.github.philippefichet.sonarlint4netbeans.remote.listener.SonarLintRemoteSyncListenerProgressHandle; +import com.github.philippefichet.sonarlint4netbeans.remote.wrapper.SonarLintRemoteHttpClient; +import java.util.Collections; +import java.util.EnumSet; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; +import java.util.logging.Logger; +import org.openide.util.Cancellable; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; +import org.sonarsource.sonarlint.core.ConnectedSonarLintEngineImpl; +import org.sonarsource.sonarlint.core.commons.progress.ClientProgressMonitor; +import org.sonarsource.sonarlint.core.serverapi.EndpointParams; +import org.sonarsource.sonarlint.core.serverapi.exception.NotFoundException; +import org.sonarsource.sonarlint.core.serverapi.exception.ServerErrorException; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteSynchronizationTask implements Cancellable, Runnable { + + private static final Logger LOG = Logger.getLogger(SonarLintRemoteSynchronizationTask.class.getName()); + + public enum SyncPolicies { + SYNC, + UPDATE_PROJECT, + DOWNLOAD_ALL_SERVER_ISSUES, + DOWNLOAD_ALL_SERVER_ISSUES_FOR_FILE, + } + + private final AtomicBoolean forceStop = new AtomicBoolean(false); + private final SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration; + private final SonarLintRemoteEnginSyncListener sonarLintRemoteEnginSyncListener; + private final Supplier connectedSonarLintEngineImplSupplier; + private final EnumSet sonarLintRemoteSyncPolicies; + + public SonarLintRemoteSynchronizationTask( + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration, + Supplier connectedSonarLintEngineImplSupplier, + EnumSet sonarLintRemoteSyncPolicies + ) { + this.sonarLintRemoteProjectConfiguration = sonarLintRemoteProjectConfiguration; + this.sonarLintRemoteEnginSyncListener = new SonarLintRemoteSyncListenerProgressHandle( + sonarLintRemoteProjectConfiguration.getProjectKey(), + this::cancel + ); + this.connectedSonarLintEngineImplSupplier = connectedSonarLintEngineImplSupplier; + this.sonarLintRemoteSyncPolicies = sonarLintRemoteSyncPolicies; + } + + @Override + public boolean cancel() { + forceStop.set(true); + return true; + } + + @Override + public void run() { + try { + sync(); + } catch (RuntimeException ex) { + cancel(); + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.CANCELLED, + "Error while sync: " + ex.getMessage() + ); + Exceptions.printStackTrace(ex); + throw ex; + } + } + private void sync() { + sonarLintRemoteEnginSyncListener.consume(SonarLintRemoteEnginSyncListener.Status.RUNNING, "Initialization ..."); + String connectionId = sonarLintRemoteProjectConfiguration.getConnectionId(); + String projectKey = sonarLintRemoteProjectConfiguration.getProjectKey(); + SonarLintRemoteConnectionConfigurationManagement sonarLintRemoteConnectionConfigurationManagement = Lookup.getDefault().lookup(SonarLintRemoteConnectionConfigurationManagement.class); + Optional sonarLintConnectionConfigurationFromConnectionId = sonarLintRemoteConnectionConfigurationManagement.getSonarLintConnectionConfigurationFromConnectionId(connectionId); + Optional authTokenFromConnectionId = sonarLintRemoteConnectionConfigurationManagement.getAuthTokenFromConnectionId(connectionId); + if (sonarLintConnectionConfigurationFromConnectionId.isEmpty()) { + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.FINISH, + "Connection not found" + ); + return; + } + if (authTokenFromConnectionId.isEmpty()) { + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.FINISH, + "Auth token not found" + ); + return; + } + + ConnectedSonarLintEngineImpl connectedSonarLintEngineImpl = connectedSonarLintEngineImplSupplier.get(); + AtomicReference prefixStep = new AtomicReference<>("Initialization"); + AtomicReference prefixMessage = new AtomicReference<>(); + AtomicInteger currentStep = new AtomicInteger(0); + SonarLintRemoteHttpClient sonarLintRemoteHttpClient = new SonarLintRemoteHttpClient( + authTokenFromConnectionId.get(), + sonarLintConnectionConfigurationFromConnectionId.get().isIsSonarCloud() + ? SonarLintRemoteHttpClient.Authentification.BEARER + : SonarLintRemoteHttpClient.Authentification.BASIC, + l -> { + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.RUNNING, + "[" + prefixStep.get() + "] " + prefixMessage.get() + " (" + l + " bytes)" + ); + if (Thread.currentThread().isInterrupted() || forceStop.get()) { + throw new IllegalStateException("Thread " + Thread.currentThread().getName() + " is interrupted"); + } + } + ); + EndpointParams endpointParams = new EndpointParams( + sonarLintConnectionConfigurationFromConnectionId.get().getBaseURL(), + sonarLintConnectionConfigurationFromConnectionId.get().isIsSonarCloud(), + sonarLintRemoteProjectConfiguration.getOrganization() + ); + ClientProgressMonitor clientProgressMonitor = new ClientProgressMonitor() { + @Override + public void setMessage(String msg) { + prefixMessage.set(msg); + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.RUNNING, + "[" + prefixStep.get() + "] " + msg + ); + LOG.info(msg); + //if (Thread.currentThread().isInterrupted()) { + if (Thread.currentThread().isInterrupted()) { + throw new IllegalStateException("Thread " + Thread.currentThread().getName() + " is interrupted"); + } + } + + @Override + public void setFraction(float fraction) { + if (fraction < 1.0 && !Float.isNaN(fraction)) + { + System.out.println("fraction = " + fraction); + } + } + + @Override + public void setIndeterminate(boolean indeterminate) { + } + }; + + + if (sonarLintRemoteSyncPolicies.contains(SyncPolicies.UPDATE_PROJECT)) { + prefixStep.set("Update project"); + currentStep.incrementAndGet(); + connectedSonarLintEngineImpl.updateProject(endpointParams, sonarLintRemoteHttpClient, projectKey, clientProgressMonitor); + } + // TODO "-J--add-exports java.base/sun.nio.ch=ALL-UNNAMED" + if (sonarLintRemoteSyncPolicies.contains(SyncPolicies.DOWNLOAD_ALL_SERVER_ISSUES)) { + prefixStep.set("Download server issues"); + currentStep.incrementAndGet(); + connectedSonarLintEngineImpl.downloadAllServerIssues(endpointParams, sonarLintRemoteHttpClient, projectKey, sonarLintRemoteProjectConfiguration.getProjectActiveBranch().orElse("main"), clientProgressMonitor); + } + + if (sonarLintRemoteSyncPolicies.contains(SyncPolicies.SYNC)) + { + prefixStep.set("Syncing ... "); + currentStep.incrementAndGet(); + try { + connectedSonarLintEngineImpl.sync( + endpointParams, + sonarLintRemoteHttpClient, + Collections.singleton(projectKey), + clientProgressMonitor + ); + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.FINISH, + "Done" + ); + } catch (IllegalStateException | NotFoundException | ServerErrorException ex) { + sonarLintRemoteEnginSyncListener.consume( + SonarLintRemoteEnginSyncListener.Status.FINISH, + "End with error: " + ex.getLocalizedMessage() + ); + } + } + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java new file mode 100644 index 0000000..1610a61 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.synchronization; + +import java.util.Objects; +import org.openide.util.RequestProcessor; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public final class TaskWrapper { + private final RequestProcessor.Task task; + private final SonarLintRemoteSynchronizationTask sonarLintRemoteSynchronizationTask; + + public TaskWrapper(RequestProcessor.Task task, SonarLintRemoteSynchronizationTask sonarLintRemoteSynchronizationTask) { + this.task = task; + this.sonarLintRemoteSynchronizationTask = sonarLintRemoteSynchronizationTask; + } + + public RequestProcessor.Task getTask() { + return task; + } + + public SonarLintRemoteSynchronizationTask getSonarLintRemoteSynchronizationTask() { + return sonarLintRemoteSynchronizationTask; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 79 * hash + Objects.hashCode(this.task); + hash = 79 * hash + Objects.hashCode(this.sonarLintRemoteSynchronizationTask); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final TaskWrapper other = (TaskWrapper) obj; + if (!Objects.equals(this.task, other.task)) { + return false; + } + return Objects.equals(this.sonarLintRemoteSynchronizationTask, other.sonarLintRemoteSynchronizationTask); + } + + +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java index ed7112c..104d418 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java @@ -18,7 +18,7 @@ */ package com.github.philippefichet.sonarlint4netbeans.remote.ui; -import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintConnectionConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfiguration; import java.awt.Component; import javax.swing.DefaultListCellRenderer; import javax.swing.JList; @@ -40,7 +40,7 @@ public Component getListCellRendererComponent( ) { DefaultListCellRenderer listCellRendererComponent = (DefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { - listCellRendererComponent.setText(((SonarLintConnectionConfiguration)value).getConnectionId()); + listCellRendererComponent.setText(((SonarLintRemoteConnectionConfiguration)value).getConnectionId()); } return listCellRendererComponent; } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form index e3be0d5..6432aff 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.form @@ -84,7 +84,7 @@ - + @@ -142,7 +142,7 @@ - + @@ -188,34 +188,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -223,10 +195,10 @@ - + - + diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java index ce8ae8e..75bf6ed 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java @@ -18,8 +18,10 @@ */ package com.github.philippefichet.sonarlint4netbeans.remote.ui; -import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintConnectionConfiguration; -import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintConnectionConfigurationManagement; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfigurationManagement; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import org.openide.util.Lookup; /** @@ -31,6 +33,8 @@ }) public class SonarLintSonarCloudPanel extends javax.swing.JPanel { + private String oldBaseURL; + /** * Creates new form SonarLintSonarCloudPanel */ @@ -38,6 +42,21 @@ public SonarLintSonarCloudPanel() { initComponents(); connectionCnfigurationComboBox.setRenderer(new SonarLintConnectionConfigurationListCellRenderer()); initConnectionCnfigurationComboBox(); + isSonarCloudCheckBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (isSonarCloudCheckBox.isSelected()) { + oldBaseURL = baseURLTextField.getText(); + baseURLTextField.setText("https://sonarcloud.io"); + baseURLTextField.setEditable(false); + baseURLTextField.setEnabled(false); + } else { + baseURLTextField.setText(oldBaseURL); + baseURLTextField.setEditable(true); + baseURLTextField.setEnabled(true); + } + } + }); } private void initConnectionCnfigurationComboBox() @@ -70,12 +89,8 @@ private void initComponents() { baseURLTextField = new javax.swing.JTextField(); isSonarCloudLabel = new javax.swing.JLabel(); isSonarCloudCheckBox = new javax.swing.JCheckBox(); - projectKeyLabel = new javax.swing.JLabel(); - projectKeyTextField = new javax.swing.JTextField(); - organizationLabel = new javax.swing.JLabel(); - organizationTextField = new javax.swing.JTextField(); authTokenLabel = new javax.swing.JLabel(); - authTokenTextField = new javax.swing.JTextField(); + authTokenPasswordField = new javax.swing.JPasswordField(); connectionSavePanel = new javax.swing.JPanel(); saveConfiguration = new javax.swing.JButton(); @@ -133,7 +148,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { connectionEditPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.connectionEditPanel.border.title"))); // NOI18N connectionEditPanel.setLayout(new java.awt.BorderLayout(5, 5)); - connectionEditDataPanel.setLayout(new java.awt.GridLayout(6, 2, 5, 5)); + connectionEditDataPanel.setLayout(new java.awt.GridLayout(4, 2, 5, 5)); org.openide.awt.Mnemonics.setLocalizedText(connectionIdLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.connectionIdLabel.text")); // NOI18N connectionEditDataPanel.add(connectionIdLabel); @@ -153,23 +168,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { org.openide.awt.Mnemonics.setLocalizedText(isSonarCloudCheckBox, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.isSonarCloudCheckBox.text")); // NOI18N connectionEditDataPanel.add(isSonarCloudCheckBox); - org.openide.awt.Mnemonics.setLocalizedText(projectKeyLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.projectKeyLabel.text")); // NOI18N - connectionEditDataPanel.add(projectKeyLabel); - - projectKeyTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.projectKeyTextField.text")); // NOI18N - connectionEditDataPanel.add(projectKeyTextField); - - org.openide.awt.Mnemonics.setLocalizedText(organizationLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.organizationLabel.text")); // NOI18N - connectionEditDataPanel.add(organizationLabel); - - organizationTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.organizationTextField.text")); // NOI18N - connectionEditDataPanel.add(organizationTextField); - org.openide.awt.Mnemonics.setLocalizedText(authTokenLabel, org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.authTokenLabel.text")); // NOI18N connectionEditDataPanel.add(authTokenLabel); - authTokenTextField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.authTokenTextField.text")); // NOI18N - connectionEditDataPanel.add(authTokenTextField); + authTokenPasswordField.setText(org.openide.util.NbBundle.getMessage(SonarLintSonarCloudPanel.class, "SonarLintSonarCloudPanel.authTokenPasswordField.text")); // NOI18N + connectionEditDataPanel.add(authTokenPasswordField); connectionEditPanel.add(connectionEditDataPanel, java.awt.BorderLayout.NORTH); @@ -202,50 +205,45 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { add(connectionEditPanel, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents - private SonarLintConnectionConfigurationManagement getSonarLintConnectionConfigurationManagement() + private SonarLintRemoteConnectionConfigurationManagement getSonarLintConnectionConfigurationManagement() { - return Lookup.getDefault().lookup(SonarLintConnectionConfigurationManagement.class); + return Lookup.getDefault().lookup(SonarLintRemoteConnectionConfigurationManagement.class); } private void saveConfigurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveConfigurationActionPerformed String connectionId = connectionIdTextField.getText(); - getSonarLintConnectionConfigurationManagement().saveSonarLintConnectionConfiguration( - new SonarLintConnectionConfiguration( + getSonarLintConnectionConfigurationManagement().saveSonarLintConnectionConfiguration(new SonarLintRemoteConnectionConfiguration( connectionId, - projectKeyTextField.getText(), baseURLTextField.getText(), - isSonarCloudCheckBox.isSelected(), - organizationTextField.getText() + isSonarCloudCheckBox.isSelected() ) ); getSonarLintConnectionConfigurationManagement().saveAuthTokenFromConnectionId( connectionId, - authTokenTextField.getText() + new String(authTokenPasswordField.getPassword()) ); initConnectionCnfigurationComboBox(); }//GEN-LAST:event_saveConfigurationActionPerformed private void editConnectionConfiguration(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editConnectionConfiguration - SonarLintConnectionConfiguration sonarLintConnectionConfiguration = - (SonarLintConnectionConfiguration)connectionCnfigurationComboBox.getSelectedItem(); + SonarLintRemoteConnectionConfiguration sonarLintConnectionConfiguration = + (SonarLintRemoteConnectionConfiguration)connectionCnfigurationComboBox.getSelectedItem(); String connectionId = sonarLintConnectionConfiguration.getConnectionId(); if (sonarLintConnectionConfiguration != null) { connectionIdTextField.setText(connectionId); - projectKeyTextField.setText(sonarLintConnectionConfiguration.getProjectKey()); baseURLTextField.setText(sonarLintConnectionConfiguration.getBaseURL()); isSonarCloudCheckBox.setSelected(sonarLintConnectionConfiguration.isIsSonarCloud()); - organizationTextField.setText(sonarLintConnectionConfiguration.getOrganization()); getSonarLintConnectionConfigurationManagement() .getAuthTokenFromConnectionId(connectionId) - .ifPresent(authTokenTextField::setText); + .ifPresent(authTokenPasswordField::setText); } }//GEN-LAST:event_editConnectionConfiguration private void removeConnectionConfiguration(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeConnectionConfiguration - SonarLintConnectionConfiguration sonarLintConnectionConfiguration = - (SonarLintConnectionConfiguration)connectionCnfigurationComboBox.getSelectedItem(); + SonarLintRemoteConnectionConfiguration sonarLintConnectionConfiguration = + (SonarLintRemoteConnectionConfiguration)connectionCnfigurationComboBox.getSelectedItem(); if (sonarLintConnectionConfiguration != null) { - SonarLintConnectionConfigurationManagement sonarLintConnectionConfigurationManagement = getSonarLintConnectionConfigurationManagement(); + SonarLintRemoteConnectionConfigurationManagement sonarLintConnectionConfigurationManagement = getSonarLintConnectionConfigurationManagement(); sonarLintConnectionConfigurationManagement.deleteAuthTokenFromConnectionId(sonarLintConnectionConfiguration.getConnectionId()); sonarLintConnectionConfigurationManagement.deleteSonarLintConnectionConfigurationFromConnectionId(sonarLintConnectionConfiguration.getConnectionId()); initConnectionCnfigurationComboBox(); @@ -255,10 +253,10 @@ private void removeConnectionConfiguration(java.awt.event.ActionEvent evt) {//GE // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel authTokenLabel; - private javax.swing.JTextField authTokenTextField; + private javax.swing.JPasswordField authTokenPasswordField; private javax.swing.JLabel baseURLLabel; private javax.swing.JTextField baseURLTextField; - private javax.swing.JComboBox connectionCnfigurationComboBox; + private javax.swing.JComboBox connectionCnfigurationComboBox; private javax.swing.JPanel connectionEditDataPanel; private javax.swing.JPanel connectionEditPanel; private javax.swing.JLabel connectionIdLabel; @@ -270,10 +268,6 @@ private void removeConnectionConfiguration(java.awt.event.ActionEvent evt) {//GE private javax.swing.JLabel isSonarCloudLabel; private javax.swing.JLabel jLabel1; private javax.swing.JPanel jPanel1; - private javax.swing.JLabel organizationLabel; - private javax.swing.JTextField organizationTextField; - private javax.swing.JLabel projectKeyLabel; - private javax.swing.JTextField projectKeyTextField; private javax.swing.JButton removeConnectionConfiguration; private javax.swing.JButton saveConfiguration; // End of variables declaration//GEN-END:variables diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java new file mode 100644 index 0000000..0884f0a --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.wrapper; + +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; +import org.sonarsource.sonarlint.core.analysis.api.Flow; +import org.sonarsource.sonarlint.core.analysis.api.QuickFix; +import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; +import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneRuleDetails; +import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.RuleType; +import org.sonarsource.sonarlint.core.commons.TextRange; +import org.sonarsource.sonarlint.core.commons.VulnerabilityProbability; +import org.sonarsource.sonarlint.core.serverconnection.issues.LineLevelServerIssue; +import org.sonarsource.sonarlint.core.serverconnection.issues.RangeLevelServerIssue; +import org.sonarsource.sonarlint.core.serverconnection.issues.ServerIssue; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintIssueWrapperForServerIssue implements Issue { + + private final ServerIssue serverIssue; + private final ClientInputFile clientInputFile; + private final Optional ruleDetails; + + public SonarLintIssueWrapperForServerIssue(ClientInputFile clientInputFile, ServerIssue serverIssue, Optional ruleDetails) { + this.clientInputFile = clientInputFile; + this.serverIssue = serverIssue; + this.ruleDetails = ruleDetails; + } + + @Override + public IssueSeverity getSeverity() { + // TODO to fix NPE. Find real user severity later + if (serverIssue.getUserSeverity() == null) { + if (ruleDetails.isPresent()) { + return ruleDetails.get().getDefaultSeverity(); + } else { + return IssueSeverity.BLOCKER; + } + } + return serverIssue.getUserSeverity(); + } + + @Override + public RuleType getType() { + return serverIssue.getType(); + } + + @Override + public String getRuleKey() { + return serverIssue.getRuleKey(); + } + + @Override + public List flows() { + return Collections.emptyList(); + } + + @Override + public List quickFixes() { + return Collections.emptyList(); + } + + @Override + public Optional getRuleDescriptionContextKey() { + return Optional.empty(); + } + + @Override + public Optional getVulnerabilityProbability() { + return Optional.empty(); + } + + @Override + public String getMessage() { + return serverIssue.getMessage(); + } + + @Override + public ClientInputFile getInputFile() { + return clientInputFile; + } + + @Override + public TextRange getTextRange() { + if (serverIssue instanceof RangeLevelServerIssue) { + return ((RangeLevelServerIssue)serverIssue).getTextRange(); + } + return null; + } + + @Override + public Integer getStartLine() { + if (serverIssue instanceof RangeLevelServerIssue) { + return ((RangeLevelServerIssue)serverIssue).getTextRange().getStartLine(); + } else if(serverIssue instanceof LineLevelServerIssue){ + return ((LineLevelServerIssue)serverIssue).getLine(); + } + return null; + } + + @Override + public Integer getStartLineOffset() { + if (serverIssue instanceof RangeLevelServerIssue) { + return ((RangeLevelServerIssue)serverIssue).getTextRange().getStartLineOffset(); + } + return null; + } + + @Override + public Integer getEndLine() { + if (serverIssue instanceof RangeLevelServerIssue) { + return ((RangeLevelServerIssue)serverIssue).getTextRange().getEndLine(); + } else if(serverIssue instanceof LineLevelServerIssue){ + return ((LineLevelServerIssue)serverIssue).getLine(); + } + return null; + } + + @Override + public Integer getEndLineOffset() { + if (serverIssue instanceof RangeLevelServerIssue) { + return ((RangeLevelServerIssue)serverIssue).getTextRange().getEndLineOffset(); + } + return null; + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java new file mode 100644 index 0000000..4c94893 --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.wrapper; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.function.Consumer; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteConsumerProgressInputStream extends InputStream { + private final Consumer responseReadByteConsumer; + private long lengthRead = 0; + private final InputStream inputStream; + + public SonarLintRemoteConsumerProgressInputStream(Consumer responseReadByteConsumer, InputStream inputStream) { + this.responseReadByteConsumer = responseReadByteConsumer; + this.inputStream = inputStream; + } + + @Override + public long transferTo(OutputStream out) throws IOException { + return inputStream.transferTo(out); + } + + @Override + public boolean markSupported() { + return inputStream.markSupported(); + } + + @Override + public synchronized void reset() throws IOException { + lengthRead = 0; + inputStream.reset(); + responseReadByteConsumer.accept(lengthRead); + } + + @Override + public synchronized void mark(int readlimit) { + inputStream.mark(readlimit); + } + + @Override + public void close() throws IOException { + inputStream.close(); + } + + @Override + public int available() throws IOException { + return inputStream.available(); + } + + @Override + public long skip(long n) throws IOException { + return inputStream.skip(n); + } + + @Override + public int readNBytes(byte[] b, int off, int len) throws IOException { + int readNBytes = inputStream.readNBytes(b, off, len); + lengthRead += readNBytes; + responseReadByteConsumer.accept(lengthRead); + return readNBytes; + } + + @Override + public byte[] readNBytes(int len) throws IOException { + byte[] readNBytes = inputStream.readNBytes(len); + lengthRead += readNBytes.length; + responseReadByteConsumer.accept(lengthRead); + return readNBytes; + } + + @Override + public byte[] readAllBytes() throws IOException { + byte[] readAllBytes = inputStream.readAllBytes(); + lengthRead += readAllBytes.length; + responseReadByteConsumer.accept(lengthRead); + return readAllBytes; + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + int read = inputStream.read(b, off, len); + lengthRead += read; + responseReadByteConsumer.accept(lengthRead); + return read; + } + + @Override + public int read(byte[] b) throws IOException { + int read = inputStream.read(b); + lengthRead += read; + responseReadByteConsumer.accept(lengthRead); + return read; + } + + @Override + public int read() throws IOException { + int read = inputStream.read(); + lengthRead += read; + responseReadByteConsumer.accept(lengthRead); + return read; + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java new file mode 100644 index 0000000..9c7994c --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.wrapper; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Base64; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.sonarsource.sonarlint.core.commons.http.HttpClient; +import org.sonarsource.sonarlint.core.commons.http.HttpConnectionListener; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteHttpClient implements HttpClient { + private static final String AUTHORIZATION_HEADER_NAME = "Authorization"; + private final java.net.http.HttpClient client = java.net.http.HttpClient.newBuilder().build(); + private final Consumer responseReadByteConsumer; + private final String login; + + public enum Authentification { + BASIC, + BEARER; + } + + public SonarLintRemoteHttpClient(String login, Authentification authentification, Consumer responseReadByteConsumer) { + this.responseReadByteConsumer = responseReadByteConsumer; + this.login = toHttpHeader(login, authentification); + } + + private String toHttpHeader(String login, SonarLintRemoteHttpClient.Authentification authentification) { + switch(authentification) { + case BEARER: + return "Bearer " + login; + case BASIC: + return "Basic " + Base64.getEncoder().encodeToString((login + ":").getBytes()); + default: + throw new UnsupportedOperationException("Authentification \"" + authentification.name() + "\" not supported"); + } + } + + @Override + public Response get(String url) { + try { + HttpResponse response = client.send( + HttpRequest.newBuilder(URI.create(url)).GET() + .header(AUTHORIZATION_HEADER_NAME, login) + .build(), + HttpResponse.BodyHandlers.ofInputStream() + ); + return new SonarLintRemoteHttpResponse(url, response, responseReadByteConsumer); + } catch (IOException ex) { + Logger.getLogger(SonarLintRemoteHttpClient.class.getName()).log(Level.SEVERE, null, ex); + // TODO cumtomize exception + throw new RuntimeException(ex); + } catch (InterruptedException ex) { + Logger.getLogger(SonarLintRemoteHttpClient.class.getName()).log(Level.SEVERE, null, ex); + Thread.currentThread().interrupt(); + // TODO cumtomize exception + throw new RuntimeException(ex); + } + } + + @Override + public CompletableFuture getAsync(String url) { + return client.sendAsync( + HttpRequest.newBuilder(URI.create(url)).GET() + .header(AUTHORIZATION_HEADER_NAME, login) + .build(), + HttpResponse.BodyHandlers.ofInputStream() + ).thenApply((HttpResponse send) -> new SonarLintRemoteHttpResponse(url, send, responseReadByteConsumer)); + } + + @Override + public AsyncRequest getEventStream(String url, HttpConnectionListener connectionListener, Consumer messageConsumer) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Response post(String url, String contentType, String body) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Response delete(String url, String contentType, String body) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + +} \ No newline at end of file diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java new file mode 100644 index 0000000..ddfbadd --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote.wrapper; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.http.HttpResponse; +import java.util.function.Consumer; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.sonarsource.sonarlint.core.commons.http.HttpClient; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SonarLintRemoteHttpResponse implements HttpClient.Response { + + private final String url; + private final HttpResponse response; + private final SonarLintRemoteConsumerProgressInputStream consumerProgressInputStream; + + public SonarLintRemoteHttpResponse(String url, HttpResponse response, Consumer responseReadByteConsumer) { + this.url = url; + this.response = response; + this.consumerProgressInputStream = new SonarLintRemoteConsumerProgressInputStream(responseReadByteConsumer, response.body()); + } + + @Override + public int code() { + return response.statusCode(); + } + + @Override + public String bodyAsString() { + System.out.println("bodyAsString"); + try (BufferedInputStream bis = new BufferedInputStream(consumerProgressInputStream)) + { + return new String(bis.readAllBytes()); + } catch (IOException ex) { + Logger.getLogger(SonarLintRemoteHttpResponse.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + + @Override + public InputStream bodyAsStream() { + System.out.println("bodyAsStream"); + return consumerProgressInputStream; + } + + @Override + public void close() { + try { + consumerProgressInputStream.close(); + } catch (IOException ex) { + Logger.getLogger(SonarLintRemoteHttpResponse.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Override + public String url() { + return url; + } + +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java index 2fab9fd..8e7bd10 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java @@ -53,6 +53,8 @@ public class SonarRuleDetailsPanel extends javax.swing.JPanel { private final SonarLintEngine sonarLintEngine; private final Project project; + // TODO See later to manage the remote case and limit interaction + /** * Creates new form SonarRuleDetailsPanel * @param sonarLintEngine SonarLintEngine instance dealing with the retrieval or modification of information diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java index 80ccaa3..1abbf3c 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java @@ -149,6 +149,7 @@ public void setSonarRuleKeyFilter(String sonarRuleKeyFilter, Project project) private SonarRuleDetailsPanel getOrCreateAndAddSonarRuleDetailsPanelFromProject(Project project) { + // TODO to be adapted to display what is possible in the case of remote scope Project searchedProject = SonarLintDataManagerUtils.getProjectForAnalyse(sonarLintDataManager, project); for (Component component : tabs.getComponents()) { if (component instanceof SonarRuleDetailsPanel) { @@ -159,11 +160,11 @@ private SonarRuleDetailsPanel getOrCreateAndAddSonarRuleDetailsPanelFromProject( } } } - + SonarRuleDetailsPanel sonarRuleDetailsPanel = new SonarRuleDetailsPanel(sonarLintEngine, searchedProject); - + String title = - sonarLintDataManager.getPreferencesScope(project) == SonarLintProjectPreferenceScope.PROJECT + sonarLintDataManager.getPreferencesScope(project) != SonarLintProjectPreferenceScope.GLOBAL ? ProjectUtils.getInformation(searchedProject).getDisplayName() : org.openide.util.NbBundle.getMessage(SonarRuleDetailsTopComponent.class, "SonarRuleDetailsTopComponent.globalSettingsProject"); diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/project/ui/Bundle.properties b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/project/ui/Bundle.properties index 3358ea3..9a9abf9 100644 --- a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/project/ui/Bundle.properties +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/project/ui/Bundle.properties @@ -1,2 +1,12 @@ SonarLintProjectCustomizerPanel.scopeProjectRadioButton.text=Use project settings SonarLintProjectCustomizerPanel.scopeGlobalRadioButton.text=Use global settings +SonarLintProjectCustomizerPanel.scopeRemoteRadioButton.text=Use remote settings +SonarLintProjectCustomizerPanel.remoteConfiguration.border.title=Remote configuration +SonarLintProjectCustomizerPanel.warningLabel.text= +SonarLintProjectCustomizerPanel.projectKeyLabel.text=Project key +SonarLintProjectCustomizerPanel.projectKeyTextField.text= +SonarLintProjectCustomizerPanel.connectionsLabel.text=Connection +SonarLintProjectCustomizerPanel.organisationLabel.text=Organisation +SonarLintProjectCustomizerPanel.organisationTextField.text= +SonarLintProjectCustomizerPanel.syncProject.text=Sync +SonarLintProjectCustomizerPanel.syncProject.textCancel=Cancel Sync ... diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties index d28727f..0f48b13 100644 --- a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/remote/ui/Bundle.properties @@ -7,11 +7,7 @@ SonarLintSonarCloudPanel.baseURLLabel.text=baseURL SonarLintSonarCloudPanel.baseURLTextField.text=http://localhost:9000 SonarLintSonarCloudPanel.isSonarCloudLabel.text=Is sonar cloud SonarLintSonarCloudPanel.isSonarCloudCheckBox.text= -SonarLintSonarCloudPanel.projectKeyLabel.text=projectKey -SonarLintSonarCloudPanel.projectKeyTextField.text= -SonarLintSonarCloudPanel.organizationLabel.text=organization -SonarLintSonarCloudPanel.organizationTextField.text= SonarLintSonarCloudPanel.authTokenLabel.text=auth token -SonarLintSonarCloudPanel.authTokenTextField.text= SonarLintSonarCloudPanel.editConnectionConfiguration.text=Edit SonarLintSonarCloudPanel.removeConnectionConfiguration.text=Remove +SonarLintSonarCloudPanel.authTokenPasswordField.text=jPasswordField1 diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java index 047b99e..f2a457b 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java @@ -20,6 +20,7 @@ package com.github.philippefichet.sonarlint4netbeans; import java.util.List; +import java.util.Optional; import org.assertj.core.groups.Tuple; import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; import org.sonarsource.sonarlint.core.analysis.api.Flow; @@ -28,6 +29,7 @@ import org.sonarsource.sonarlint.core.commons.IssueSeverity; import org.sonarsource.sonarlint.core.commons.RuleType; import org.sonarsource.sonarlint.core.commons.TextRange; +import org.sonarsource.sonarlint.core.commons.VulnerabilityProbability; /** * @@ -133,11 +135,22 @@ public List quickFixes() { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + @Override + public Optional getRuleDescriptionContextKey() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Optional getVulnerabilityProbability() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + @Override public String toString() { return "DefaultIssueTestImpl{" + "severity=" + severity + ", type=" + type + ", ruleKey=" + ruleKey + ", startLine=" + startLine + ", endLine=" + endLine + ", startLineOffset=" + startLineOffset + ", endLineOffset=" + endLineOffset + ", clientInputFile=" + clientInputFile + '}'; } + public static class Builder { private IssueSeverity severity; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java index 11ac760..4146161 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; import java.util.Arrays; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java index bacdfcd..948dbc9 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java index 6015ca1..33696c2 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java index 0cb5d38..f46cc5d 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; import java.net.MalformedURLException; import java.util.Map; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java index 8b4ff03..d06abf3 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java index bf1f928..4d493af 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java index 3db15de..400e508 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; import com.github.philippefichet.sonarlint4netbeans.treenode.SonarLintAnalyzerRootNode; import java.io.File; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintLookupMockedExtension.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java similarity index 98% rename from src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintLookupMockedExtension.java rename to src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java index d20b43c..70150b7 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintLookupMockedExtension.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java @@ -17,8 +17,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.github.philippefichet.sonarlint4netbeans; +package com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension; +import com.github.philippefichet.sonarlint4netbeans.Predicates; import com.github.philippefichet.sonarlint4netbeans.assertj.SonarLintArgumentMatchers; import java.lang.reflect.Method; import java.util.HashMap; From f0a5fe1b8c3614c9c41cf40ff4997a3dc6b2adbf Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Sun, 10 Dec 2023 21:16:44 +0100 Subject: [PATCH 03/17] Fix compile issue from merge --- pom.xml | 5 +++++ .../SonarLintIssueWrapperForServerIssue.java | 18 ++++++++++++++++++ .../wrapper/SonarLintRemoteHttpClient.java | 13 +++++++++++-- .../wrapper/SonarLintRemoteHttpResponse.java | 2 +- .../DefaultIssueTestImpl.java | 6 ------ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 9a42119..656914e 100644 --- a/pom.xml +++ b/pom.xml @@ -109,6 +109,11 @@
+ + org.apache.maven.plugins + maven-surefire-report-plugin + 3.2.2 + org.jacoco jacoco-maven-plugin diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java index 0884f0a..94a4cff 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java @@ -20,14 +20,18 @@ import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Optional; import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; import org.sonarsource.sonarlint.core.analysis.api.Flow; import org.sonarsource.sonarlint.core.analysis.api.QuickFix; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneRuleDetails; +import org.sonarsource.sonarlint.core.commons.CleanCodeAttribute; +import org.sonarsource.sonarlint.core.commons.ImpactSeverity; import org.sonarsource.sonarlint.core.commons.IssueSeverity; import org.sonarsource.sonarlint.core.commons.RuleType; +import org.sonarsource.sonarlint.core.commons.SoftwareQuality; import org.sonarsource.sonarlint.core.commons.TextRange; import org.sonarsource.sonarlint.core.commons.VulnerabilityProbability; import org.sonarsource.sonarlint.core.serverconnection.issues.LineLevelServerIssue; @@ -146,4 +150,18 @@ public Integer getEndLineOffset() { } return null; } + + @Override + public Optional getCleanCodeAttribute() { + // TODO + return Optional.empty(); + } + + @Override + public Map getImpacts() { + // TODO + return Collections.emptyMap(); + } + + } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java index 9c7994c..277844d 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java @@ -23,13 +23,16 @@ import java.net.URI; import java.net.http.HttpRequest; import java.net.http.HttpResponse; +import java.net.http.WebSocket; import java.util.Base64; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; -import org.sonarsource.sonarlint.core.commons.http.HttpClient; -import org.sonarsource.sonarlint.core.commons.http.HttpConnectionListener; +import org.sonarsource.sonarlint.core.http.HttpClient; +import org.sonarsource.sonarlint.core.http.HttpClient.AsyncRequest; +import org.sonarsource.sonarlint.core.http.HttpClient.Response; +import org.sonarsource.sonarlint.core.http.HttpConnectionListener; /** * @@ -94,6 +97,12 @@ public CompletableFuture getAsync(String url) { ).thenApply((HttpResponse send) -> new SonarLintRemoteHttpResponse(url, send, responseReadByteConsumer)); } + @Override + public WebSocket createWebSocketConnection(String string, Consumer cnsmr, Runnable r) { + // TODO ? + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + @Override public AsyncRequest getEventStream(String url, HttpConnectionListener connectionListener, Consumer messageConsumer) { throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java index ddfbadd..14efdc5 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java @@ -25,7 +25,7 @@ import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; -import org.sonarsource.sonarlint.core.commons.http.HttpClient; +import org.sonarsource.sonarlint.core.http.HttpClient; /** * diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java index d551548..f6f1509 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java @@ -154,11 +154,6 @@ public Map getImpacts() { throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } - @Override - public String toString() { - return "DefaultIssueTestImpl{" + "severity=" + severity + ", type=" + type + ", ruleKey=" + ruleKey + ", startLine=" + startLine + ", endLine=" + endLine + ", startLineOffset=" + startLineOffset + ", endLineOffset=" + endLineOffset + ", clientInputFile=" + clientInputFile + '}'; - } - @Override public Optional getRuleDescriptionContextKey() { throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody @@ -169,7 +164,6 @@ public Optional getVulnerabilityProbability() { throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody } - public static class Builder { private IssueSeverity severity; From 2e39408c2e6f199e853673ece63ec6aa720d6c80 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Sun, 10 Dec 2023 22:42:31 +0100 Subject: [PATCH 04/17] Add github action to show test result --- .github/workflows/maven.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 70fc885..c58fbed 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,3 +24,13 @@ jobs: - name: Build with Maven run: mvn clean package source:jar javadoc:jar verify spotless:check timeout-minutes: 10 + - name: Test Report + uses: dorny/test-reporter@v1 + if: success() || failure() # run this step even if previous step failed + with: + # Name of the check run which will be created + name: JUnit Tests + # Path to test results + path: target/surefire-reports/*.xml + # Format of test results + reporter: java-junit From 8afd46cd962e768f5ce80ea3d4c6dfa5b045aa2d Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Sun, 17 Dec 2023 23:17:54 +0100 Subject: [PATCH 05/17] Fix testing --- .../sonarlint4netbeans/SonarLintUtils.java | 10 ++-- .../SonarLintUtilsTest.java | 49 ++++++++++++++++--- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java index d019d6e..7e7d9de 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java @@ -252,7 +252,6 @@ public static String toURL(RuleDetails ruleDetails) public static List analyze(FileObject fileObject, String contentToAnalyze) throws IOException { // TODO scope remote = changement de moteur FileObject configRoot = FileUtil.getConfigRoot(); - System.out.println("configRoot = " + configRoot); SonarLintEngine sonarLintEngine = Lookup.getDefault().lookup(SonarLintEngine.class); if (sonarLintEngine == null) { return Collections.emptyList(); @@ -267,7 +266,7 @@ public static List analyze(FileObject fileObject, String contentToAnalyze boolean useTestRules = sonarlintOptions == null || sonarlintOptions.applyDifferentRulesOnTestFiles(); Project project = dataManager.getProject(fileObject).orElse(SonarLintEngine.GLOBAL_SETTINGS_PROJECT); Path path = project == null - ? toFile.toPath() + ? toFile.getParentFile().toPath() : FileUtil.toFile(project.getProjectDirectory()).toPath(); List clientInputFiles = new ArrayList<>(); boolean applyTestRules = useTestRules && dataManager.isTest(toFile); @@ -354,13 +353,16 @@ public void setIndeterminate(boolean indeterminate) { .putAllExtraProperties(getMergedExtraPropertiesAndReplaceVariables(sonarLintEngine, dataManager.getProject(fileObject).orElse(SonarLintEngine.GLOBAL_SETTINGS_PROJECT))) .build(); - + LOG.info("Start analyze ..."); AnalysisResults analyze = sonarLintEngine.analyze( standaloneAnalysisConfiguration, issues::add, - null, + // TODO create Output + (String formattedMessage, ClientLogOutput.Level level) -> + LOG.info("[" + level.name() + "] " + formattedMessage), null ); + LOG.info("End analyze"); LOG.fine(() -> "Analyze result for file \"" + fileObject.getPath() + "\" : " + analyze); return issues; } diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java index f7ec332..c08ad00 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java @@ -254,9 +254,13 @@ void ruleParameterChangedOnProjectWithGlobalScope() throws IOException, BackingS SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); String ruleKeyString = "java:S115"; Project project = mockedFirstProjectWithGlobalScope; - sonarLintEngine.getAllRuleDetails().forEach(ruleKey -> sonarLintEngine.excludeRuleKey(RuleKey.parse(ruleKey.getKey()), SonarLintEngine.GLOBAL_SETTINGS_PROJECT)); + List allRuleKey = sonarLintEngine.getAllRuleDetails() + .stream() + .map( (StandaloneRuleDetails standaloneRuleDetails) -> RuleKey.parse(standaloneRuleDetails.getKey())) + .collect(Collectors.toList()); + sonarLintEngine.excludeRuleKeys(allRuleKey, SonarLintEngine.GLOBAL_SETTINGS_PROJECT); sonarLintEngine.includeRuleKey(RuleKey.parse(ruleKeyString), SonarLintEngine.GLOBAL_SETTINGS_PROJECT); - sonarLintEngine.getAllRuleDetails().forEach(ruleKey -> sonarLintEngine.excludeRuleKey(RuleKey.parse(ruleKey.getKey()), project)); + sonarLintEngine.excludeRuleKeys(allRuleKey, project); sonarLintEngine.includeRuleKey(RuleKey.parse(ruleKeyString), project); File sonarlintFileDemo = FileUtil.normalizeFile(new File("./src/test/resources/SonarLintFileDemo.java").getAbsoluteFile()); File sonarlintFileDemoOnFakeProject = FileUtil.normalizeFile(new File("./src/test/resources/fakeproject/SonarLintFileDemo.java").getAbsoluteFile()); @@ -264,6 +268,8 @@ void ruleParameterChangedOnProjectWithGlobalScope() throws IOException, BackingS FileObject toFileObjectOnFakeProject = FileUtil.toFileObject(sonarlintFileDemoOnFakeProject); Mockito.when(sonarlintDataMangerMocked.getProject(toFileObjectOnFakeProject)) .thenReturn(Optional.of(project)); + Mockito.when(project.getProjectDirectory()) + .thenReturn(FileUtil.toFileObject(sonarlintFileDemoOnFakeProject.getParentFile())); List issues = new ArrayList<>(); List issuesOnFakeProject = new ArrayList<>(); sonarLintEngine.setRuleParameter(ruleKeyString, "format", "^.+$", project); @@ -277,10 +283,22 @@ void ruleParameterChangedOnProjectWithGlobalScope() throws IOException, BackingS new String(Files.readAllBytes(sonarlintFileDemoOnFakeProject.toPath())) )); // Then + Tuple expectedIssue = new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.CRITICAL) + .type(RuleType.CODE_SMELL) + // "Constant names should comply with a naming convention" + .ruleKey("java:S115") + .startLine(25) + .startLineOffset(31) + .endLine(25) + .endLineOffset(56) + .buildTuple(); Assertions.assertThat(issues) - .hasSize(1); + .extracting(DefaultIssueTestImpl::toTuple) + .containsExactly(expectedIssue); Assertions.assertThat(issuesOnFakeProject) - .hasSize(1); + .extracting(DefaultIssueTestImpl::toTuple) + .containsExactly(expectedIssue); } @Test @@ -299,6 +317,8 @@ void ruleParameterChangedOnProject() throws IOException, BackingStoreException { FileObject toFileObjectOnFakeProject = FileUtil.toFileObject(sonarlintFileDemoOnFakeProject); Mockito.when(sonarlintDataMangerMocked.getProject(toFileObjectOnFakeProject)) .thenReturn(Optional.of(mockedProjectWithProjectScope)); + Mockito.when(mockedProjectWithProjectScope.getProjectDirectory()) + .thenReturn(FileUtil.toFileObject(sonarlintFileDemoOnFakeProject.getParentFile())); List issues = new ArrayList<>(); List issuesOnFakeProject = new ArrayList<>(); sonarLintEngine.setRuleParameter(ruleKeyString, "format", "^.+$", mockedProjectWithProjectScope); @@ -312,10 +332,21 @@ void ruleParameterChangedOnProject() throws IOException, BackingStoreException { new String(Files.readAllBytes(sonarlintFileDemoOnFakeProject.toPath())) )); // Then + Tuple expectedIssue = new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.CRITICAL) + .type(RuleType.CODE_SMELL) + // "Constant names should comply with a naming convention" + .ruleKey("java:S115") + .startLine(25) + .startLineOffset(31) + .endLine(25) + .endLineOffset(56) + .buildTuple(); Assertions.assertThat(issues) - .hasSize(1); + .extracting(DefaultIssueTestImpl::toTuple) + .containsExactly(expectedIssue); Assertions.assertThat(issuesOnFakeProject) - .isEqualTo(Collections.emptyList()); + .isEmpty(); } @Test @@ -392,10 +423,16 @@ void extraPropertiesOnProject() throws IOException, BackingStoreException { FileObject toFileObject = FileUtil.toFileObject(sonarlintFileDemo); FileObject toFileObjectOnFakeProject = FileUtil.toFileObject(sonarlintFileDemoOnFakeProject); FileObject toFileObjectOnFakeProject2 = FileUtil.toFileObject(sonarlintFileDemoOnFakeProject2); + Mockito.when(sonarlintDataMangerMocked.getProject(toFileObjectOnFakeProject)) .thenReturn(Optional.of(mockedProjectWithProjectScope)); + Mockito.when(mockedProjectWithProjectScope.getProjectDirectory()) + .thenReturn(FileUtil.toFileObject(sonarlintFileDemo.getParentFile())); + Mockito.when(sonarlintDataMangerMocked.getProject(toFileObjectOnFakeProject2)) .thenReturn(Optional.of(mockedFirstProjectWithGlobalScope)); + Mockito.when(mockedFirstProjectWithGlobalScope.getProjectDirectory()) + .thenReturn(FileUtil.toFileObject(sonarlintFileDemoOnFakeProject2.getParentFile())); List issues = new ArrayList<>(); List issuesOnFakeProject = new ArrayList<>(); List issuesOnFakeProject2 = new ArrayList<>(); From b16bc1145a0d15688a15591f02880ab686d1a540 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Mon, 18 Dec 2023 18:32:45 +0100 Subject: [PATCH 06/17] Update license year --- license-header | 2 +- .../sonarlint4netbeans/AnalysisResultsMergerable.java | 2 +- .../sonarlint4netbeans/ClientInputFileListener.java | 2 +- .../philippefichet/sonarlint4netbeans/FSClientInputFile.java | 2 +- .../sonarlint4netbeans/NodeBundlePathResolver.java | 2 +- .../philippefichet/sonarlint4netbeans/NodeProcessWrapper.java | 2 +- .../sonarlint4netbeans/SonarLintAnalyzerAction.java | 2 +- .../sonarlint4netbeans/SonarLintAnalyzerCancelableTask.java | 2 +- .../SonarLintAnalyzerOpenIssueInFileAction.java | 2 +- .../sonarlint4netbeans/SonarLintAnalyzersTableModel.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintDataManager.java | 2 +- .../sonarlint4netbeans/SonarLintDataManagerImpl.java | 2 +- .../sonarlint4netbeans/SonarLintDataManagerUtils.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintEngine.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintGlyphAction.java | 2 +- .../sonarlint4netbeans/SonarLintListMouseAdapter.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintOptions.java | 2 +- .../sonarlint4netbeans/SonarLintParserResultTask.java | 2 +- .../sonarlint4netbeans/SonarLintParserResultTaskFactory.java | 2 +- .../sonarlint4netbeans/SonarLintPropertiesTableModel.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintUtils.java | 2 +- .../sonarlint4netbeans/annotation/SonarLintAnnotation.java | 2 +- .../annotation/SonarLintAnnotationHandler.java | 2 +- .../sonarlint4netbeans/project/SonarLintProjectCustomizer.java | 2 +- .../project/SonarLintProjectPreferenceScope.java | 2 +- .../project/ui/SonarLintProjectCustomizerPanel.java | 2 +- .../project/ui/SonarLintProjectCustomizerRulesPanel.java | 2 +- .../project/ui/SonarLintProjectPropertiesPanel.java | 2 +- .../sonarlint4netbeans/treenode/LocationProperty.java | 2 +- .../sonarlint4netbeans/treenode/RuleNameProperty.java | 2 +- .../sonarlint4netbeans/treenode/SeverityProperty.java | 2 +- .../treenode/SonarLintAnalyserIssueChildren.java | 2 +- .../treenode/SonarLintAnalyserIssueComparator.java | 2 +- .../sonarlint4netbeans/treenode/SonarLintAnalyserIssueNode.java | 2 +- .../treenode/SonarLintAnalyserIssueSeverityChildren.java | 2 +- .../treenode/SonarLintAnalyserIssueSeverityNode.java | 2 +- .../treenode/SonarLintAnalyserIssueSeverityRuleKeyChildren.java | 2 +- .../treenode/SonarLintAnalyserIssueSeverityRuleKeyNode.java | 2 +- .../sonarlint4netbeans/treenode/SonarLintAnalyzerRootNode.java | 2 +- .../sonarlint4netbeans/treenode/TypeProperty.java | 2 +- .../sonarlint4netbeans/ui/DesktopHyperlinkListener.java | 2 +- .../ui/SonarLintAnalyzerActionTopComponent.java | 2 +- .../ui/SonarLintAnalyzerOutlineContainer.java | 2 +- .../sonarlint4netbeans/ui/SonarLintOptionsPanelAnalyzers.java | 2 +- .../sonarlint4netbeans/ui/SonarLintOptionsPanelController.java | 2 +- .../sonarlint4netbeans/ui/SonarLintOptionsPanelOptions.java | 2 +- .../ui/SonarLintOptionsPanelOptionsListener.java | 2 +- .../sonarlint4netbeans/ui/SonarLintOptionsPanelPlugins.java | 2 +- .../sonarlint4netbeans/ui/SonarLintOptionsPanelProperties.java | 2 +- .../philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java | 2 +- .../sonarlint4netbeans/ui/SonarLintPanelChangedListener.java | 2 +- .../sonarlint4netbeans/ui/SonarLintRuleListPanel.java | 2 +- .../sonarlint4netbeans/ui/SonarLintRuleSettings.java | 2 +- .../sonarlint4netbeans/ui/SonarLintRuleTableModel.java | 2 +- .../sonarlint4netbeans/ui/SonarRuleDetailsPanel.java | 2 +- .../sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java | 2 +- .../ui/listener/SonarLintOptionsPanelPluginsListener.java | 2 +- .../ui/listener/SonarLintOptionsPanelPropertiesListener.java | 2 +- .../ui/listener/SonarLintRuleListPanelListener.java | 2 +- .../ui/listener/SonarLintRuleSettingsListener.java | 2 +- .../ui/renderer/SonarLintListCellRenderer.java | 2 +- .../ui/renderer/SonarLintRuleKeyTableCellRenderer.java | 2 +- .../ui/renderer/SonarLintSettingsTableCellRenderer.java | 2 +- .../ui/renderer/SonarLintSeverityTableCellRenderer.java | 2 +- .../sonarlint4netbeans/SonarLintEngineImplTestUtils.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java | 2 +- 68 files changed, 68 insertions(+), 68 deletions(-) diff --git a/license-header b/license-header index b7886ef..119904c 100644 --- a/license-header +++ b/license-header @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/AnalysisResultsMergerable.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/AnalysisResultsMergerable.java index 030a00f..edf56f2 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/AnalysisResultsMergerable.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/AnalysisResultsMergerable.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ClientInputFileListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ClientInputFileListener.java index 33ec088..ace7537 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ClientInputFileListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ClientInputFileListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java index d2d60b4..4d99986 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolver.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolver.java index e31d21d..c9e8628 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolver.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolver.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeProcessWrapper.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeProcessWrapper.java index 754e1bc..8272414 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeProcessWrapper.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/NodeProcessWrapper.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerAction.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerAction.java index 21e3400..c846b68 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerAction.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerAction.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerCancelableTask.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerCancelableTask.java index 2036170..06ce939 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerCancelableTask.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerCancelableTask.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerOpenIssueInFileAction.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerOpenIssueInFileAction.java index 4ebfe3d..fcab1b5 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerOpenIssueInFileAction.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzerOpenIssueInFileAction.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzersTableModel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzersTableModel.java index 886fd82..f6b5ecf 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzersTableModel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyzersTableModel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java index 9ed5854..00faf69 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java index 0281998..1f8ce36 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerUtils.java index 9aeb456..2332e89 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerUtils.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngine.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngine.java index 4c33cb2..7797ba3 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngine.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngine.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java index ade67f5..74765f9 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintGlyphAction.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintGlyphAction.java index 8cefd0f..0b6adf8 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintGlyphAction.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintGlyphAction.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintListMouseAdapter.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintListMouseAdapter.java index aa66e44..d00889a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintListMouseAdapter.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintListMouseAdapter.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java index 01b0081..5125a95 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintOptions.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTask.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTask.java index 27f6509..a974d87 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTask.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTask.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTaskFactory.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTaskFactory.java index 7adfe81..5a4b25a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTaskFactory.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintParserResultTaskFactory.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPropertiesTableModel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPropertiesTableModel.java index f187c0a..e6f86a0 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPropertiesTableModel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPropertiesTableModel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java index 456c47d..596b790 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java index 0c1da9e..9540320 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java index fbad3e2..17a1e59 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java index f4c1d50..abe55a2 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectCustomizer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectCustomizer.java index a5f3ee7..f54f598 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectCustomizer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectCustomizer.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java index 294a7d1..71bed75 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/SonarLintProjectPreferenceScope.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java index 11119ad..60d9dee 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerPanel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerRulesPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerRulesPanel.java index 99f4607..0aa1613 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerRulesPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectCustomizerRulesPanel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectPropertiesPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectPropertiesPanel.java index ab88f22..d494507 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectPropertiesPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/project/ui/SonarLintProjectPropertiesPanel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/LocationProperty.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/LocationProperty.java index d5c5426..e9887f7 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/LocationProperty.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/LocationProperty.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/RuleNameProperty.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/RuleNameProperty.java index 994635f..0991801 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/RuleNameProperty.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/RuleNameProperty.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SeverityProperty.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SeverityProperty.java index 9ddcba8..ced7730 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SeverityProperty.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SeverityProperty.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueChildren.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueChildren.java index 8d9efe2..56ff55f 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueChildren.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueChildren.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueComparator.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueComparator.java index 1facf12..00a3147 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueComparator.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueComparator.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueNode.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueNode.java index d9c188a..7857351 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueNode.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueNode.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityChildren.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityChildren.java index 183ab43..a4e718f 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityChildren.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityChildren.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityNode.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityNode.java index f055978..827a399 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityNode.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityNode.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyChildren.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyChildren.java index 5fbe254..fe2bac9 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyChildren.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyChildren.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyNode.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyNode.java index 6e212d0..f95fe0f 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyNode.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyserIssueSeverityRuleKeyNode.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyzerRootNode.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyzerRootNode.java index 08e769f..3556053 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyzerRootNode.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/SonarLintAnalyzerRootNode.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/TypeProperty.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/TypeProperty.java index 5e03523..3017a9a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/TypeProperty.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/treenode/TypeProperty.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/DesktopHyperlinkListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/DesktopHyperlinkListener.java index 1e84051..2cfca81 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/DesktopHyperlinkListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/DesktopHyperlinkListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerActionTopComponent.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerActionTopComponent.java index a37438a..c0f2148 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerActionTopComponent.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerActionTopComponent.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerOutlineContainer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerOutlineContainer.java index 2915a03..de8a3f2 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerOutlineContainer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintAnalyzerOutlineContainer.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelAnalyzers.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelAnalyzers.java index 0af6fb4..b71f9b9 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelAnalyzers.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelAnalyzers.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelController.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelController.java index 3023ab7..f68d4d9 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelController.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelController.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptions.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptions.java index 2707585..459261d 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptions.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptions.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptionsListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptionsListener.java index 746dab7..1fa551d 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptionsListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelOptionsListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelPlugins.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelPlugins.java index afa41af..8727231 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelPlugins.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelPlugins.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelProperties.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelProperties.java index b775f31..406f6ef 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelProperties.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintOptionsPanelProperties.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java index 97fbde6..cb62bea 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanelChangedListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanelChangedListener.java index 245ffc7..d7b1664 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanelChangedListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintPanelChangedListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleListPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleListPanel.java index d9df2a9..d1c0f9a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleListPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleListPanel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleSettings.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleSettings.java index 44c6876..3a3eab6 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleSettings.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleSettings.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleTableModel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleTableModel.java index e008a34..525ab7e 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleTableModel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarLintRuleTableModel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java index 2fab9fd..68e2cb9 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsPanel.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java index 80ccaa3..a0d72eb 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/SonarRuleDetailsTopComponent.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPluginsListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPluginsListener.java index 97611c3..32f5091 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPluginsListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPluginsListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPropertiesListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPropertiesListener.java index 7f06481..8163612 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPropertiesListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintOptionsPanelPropertiesListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleListPanelListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleListPanelListener.java index ccf28b9..3ad219e 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleListPanelListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleListPanelListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleSettingsListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleSettingsListener.java index 7e8afd2..5e5ad56 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleSettingsListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/listener/SonarLintRuleSettingsListener.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintListCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintListCellRenderer.java index d752501..f23b650 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintListCellRenderer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintListCellRenderer.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintRuleKeyTableCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintRuleKeyTableCellRenderer.java index f60dd79..1e0fc8d 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintRuleKeyTableCellRenderer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintRuleKeyTableCellRenderer.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSettingsTableCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSettingsTableCellRenderer.java index 0533884..fe6d6cc 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSettingsTableCellRenderer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSettingsTableCellRenderer.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSeverityTableCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSeverityTableCellRenderer.java index 90bcfef..d751a4f 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSeverityTableCellRenderer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/ui/renderer/SonarLintSeverityTableCellRenderer.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java index d124bc5..43c52aa 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java index cc7c812..f066be0 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public From 66ffd42abe902f7d35149d30e6327b2d17d0d4f4 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Mon, 18 Dec 2023 20:18:54 +0100 Subject: [PATCH 07/17] Fix license year --- .../philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java | 2 +- .../sonarlint4netbeans/NodeBundlePathResolverTest.java | 2 +- .../github/philippefichet/sonarlint4netbeans/Predicates.java | 2 +- .../philippefichet/sonarlint4netbeans/ProjectMockedBuilder.java | 2 +- .../SonarLintAnalyserIssueComparatorTest.java | 2 +- .../sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java | 2 +- .../sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java | 2 +- .../SonarLintEngineImplJavascriptPluginTest.java | 2 +- .../sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java | 2 +- .../sonarlint4netbeans/SonarLintEngineImplTest.java | 2 +- .../sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java | 2 +- .../sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java | 2 +- .../sonarlint4netbeans/SonarLintEngineTestConfiguration.java | 2 +- .../sonarlint4netbeans/SonarLintPreferencesForTesting.java | 2 +- .../philippefichet/sonarlint4netbeans/SonarLintTestUtils.java | 2 +- .../sonarlint4netbeans/assertj/SonarLintArgumentMatchers.java | 2 +- .../junit/jupiter/extension/SonarLintLookupMockedExtension.java | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java index f6f1509..b5252d8 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolverTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolverTest.java index 7e3b147..92a66d5 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolverTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/NodeBundlePathResolverTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/Predicates.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/Predicates.java index 1b6413f..48a4b6f 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/Predicates.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/Predicates.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/ProjectMockedBuilder.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/ProjectMockedBuilder.java index 28d0ab2..5ec8698 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/ProjectMockedBuilder.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/ProjectMockedBuilder.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java index afc4d9f..174e018 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java index 118da49..0366686 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java index 4146161..15ed31f 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java index bbcb6c4..d19eba8 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java index 33696c2..c3a0563 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java index f46cc5d..a0f62a8 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java index d06abf3..266ef39 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java index 4d493af..b39475a 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java index 603a91e..0e49acc 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPreferencesForTesting.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPreferencesForTesting.java index 3e7f851..89eb84d 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPreferencesForTesting.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintPreferencesForTesting.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTestUtils.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTestUtils.java index fdeb269..29aa5ad 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTestUtils.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTestUtils.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/assertj/SonarLintArgumentMatchers.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/assertj/SonarLintArgumentMatchers.java index 0f23f17..d6b2f4e 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/assertj/SonarLintArgumentMatchers.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/assertj/SonarLintArgumentMatchers.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java index 70150b7..81ad6bd 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java @@ -1,6 +1,6 @@ /* * sonarlint4netbeans: SonarLint integration for Apache Netbeans - * Copyright (C) 2022 Philippe FICHET. + * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public From 952bfa268786a77e7e4a5c43dcbe4aad33c313c0 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Mon, 18 Dec 2023 20:32:49 +0100 Subject: [PATCH 08/17] Fix license --- .../sonarlint4netbeans/remote/SonarLintRemoteEngine.java | 1 + .../sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java | 1 + .../configuration/SonarLintRemoteConnectionConfiguration.java | 1 + .../SonarLintRemoteConnectionConfigurationManagement.java | 1 + .../configuration/SonarLintRemoteProjectConfiguration.java | 1 + .../remote/listener/SonarLintRemoteEnginSyncListener.java | 1 + .../listener/SonarLintRemoteSyncListenerProgressHandle.java | 1 + .../remote/project/SonarLintSyncTaskProjectOpenedHook.java | 1 + .../synchronization/SonarLintRemoteSynchronizationTask.java | 1 + .../sonarlint4netbeans/remote/synchronization/TaskWrapper.java | 1 + .../ui/SonarLintConnectionConfigurationListCellRenderer.java | 1 + .../sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java | 1 + .../remote/wrapper/SonarLintIssueWrapperForServerIssue.java | 1 + .../wrapper/SonarLintRemoteConsumerProgressInputStream.java | 1 + .../remote/wrapper/SonarLintRemoteHttpClient.java | 1 + .../remote/wrapper/SonarLintRemoteHttpResponse.java | 1 + 16 files changed, 16 insertions(+) diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java index 2349f2e..bfe4b98 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java index 07cfaea..c301824 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineUtils.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java index 5528266..7b364ca 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfiguration.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java index f07f642..56d7442 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteConnectionConfigurationManagement.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java index ea0ad88..dc35f3a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java index 8443dc2..d658dce 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteEnginSyncListener.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java index 32d185d..ee8260a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/listener/SonarLintRemoteSyncListenerProgressHandle.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java index 5537c87..2297cf9 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/project/SonarLintSyncTaskProjectOpenedHook.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java index 73acf06..42fa022 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/SonarLintRemoteSynchronizationTask.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java index 1610a61..edb5341 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/synchronization/TaskWrapper.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java index 104d418..6c29e92 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintConnectionConfigurationListCellRenderer.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java index 75bf6ed..4be5bd7 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/ui/SonarLintSonarCloudPanel.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java index 94a4cff..178b069 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java index 4c94893..5f1ed3e 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteConsumerProgressInputStream.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java index 277844d..2a05105 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpClient.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java index 14efdc5..574b5fc 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintRemoteHttpResponse.java @@ -1,4 +1,5 @@ /* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans * Copyright (C) 2023 Philippe FICHET. * * This library is free software; you can redistribute it and/or From 106bb3ad91c7d3cf074a5daeb03f485a64462fa5 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 21 Dec 2023 18:07:58 +0100 Subject: [PATCH 09/17] Optimize test and add Remote test with sonarcloud --- .github/workflows/maven.yml | 4 +- pom.xml | 13 +- .../SonarLintDataManager.java | 9 +- .../SonarLintDataManagerImpl.java | 9 ++ .../SonarLintEngineImpl.java | 11 +- .../remote/SonarLintRemoteEngine.java | 17 ++- .../SonarLintRemoteProjectConfiguration.java | 10 +- .../SonarLintDataManagerMockedBuilder.java | 19 +++ .../SonarLintEngineImplJavaPluginTest.java | 5 + ...narLintEngineImplJavascriptPluginTest.java | 8 +- .../SonarLintEngineImplPhpPluginTest.java | 2 + .../SonarLintEngineImplTest.java | 5 +- .../SonarLintEngineImplTestUtils.java | 2 +- .../SonarLintEngineImplWebPluginTest.java | 2 + .../SonarLintEngineImplXmlPluginTest.java | 2 + .../SonarLintEngineTestConfiguration.java | 13 ++ .../SonarLintUtilsTest.java | 41 +++--- .../SonarLintEngineEnableLanguage.java | 37 +++++ .../SonarLintLookupMockedExtension.java | 27 +++- .../remote/SonarLintRemoteEngineTest.java | 128 ++++++++++++++++++ src/test/resources/logging.properties | 4 +- .../com/mycompany/mavenproject1/NewClass.java | 83 ++++++++++++ 22 files changed, 411 insertions(+), 40 deletions(-) create mode 100644 src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintEngineEnableLanguage.java create mode 100644 src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java create mode 100644 src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index c58fbed..0ad5293 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -22,7 +22,9 @@ jobs: java-version: 11 distribution: temurin - name: Build with Maven - run: mvn clean package source:jar javadoc:jar verify spotless:check + env: + SONARLINT4NETBEANS_TEST_REMOTE_PROJECT_MAVEN1_TOKEN: ${{ secrets.SONAR_TOKEN }} + run: mvn -D clean package source:jar javadoc:jar verify spotless:check timeout-minutes: 10 - name: Test Report uses: dorny/test-reporter@v1 diff --git a/pom.xml b/pom.xml index 81fa259..0b568b6 100644 --- a/pom.xml +++ b/pom.xml @@ -106,6 +106,11 @@ sonarlint4netbeans.test.skip.javascript ${sonarlint4netbeans.test.skip.javascript} + + + sonarlint4netbeans.test.remote.project-maven1.token + ${sonarlint4netbeans.test.remote.project-maven1.token} + @@ -135,11 +140,6 @@ maven-surefire-report-plugin 3.2.2 - - org.apache.maven.plugins - maven-surefire-report-plugin - 3.2.2 - org.jacoco jacoco-maven-plugin @@ -516,5 +516,8 @@ plain warn + + ${env.SONARLINT4NETBEANS_TEST_REMOTE_PROJECT_MAVEN1_TOKEN} + diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java index 00faf69..69559a7 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManager.java @@ -34,10 +34,17 @@ * @author FICHET Philippe <philippe.fichet@laposte.net> */ public interface SonarLintDataManager { + /** + * Retrieve project preferences data for remote configuration (sonarcloud/sonarqube) + * @param project project to retrieve preference + * @return project preferences data for remote configuration (sonarcloud/sonarqube) or global settings preference if project is null + */ + public Preferences getRemoteConfigurationPreferences(Project project); + /** * Retrieve project preferences data * @param project project to retrieve preference - * @return project preferences data or global settings preference if project if null + * @return project preferences data or global settings preference if project is null */ public Preferences getPreferences(Project project); diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java index 1f8ce36..4ecba50 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerImpl.java @@ -20,6 +20,7 @@ package com.github.philippefichet.sonarlint4netbeans; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; import java.awt.Image; import java.io.File; import java.nio.charset.Charset; @@ -43,6 +44,14 @@ */ public class SonarLintDataManagerImpl implements SonarLintDataManager { private static final String PREFERENCE_SCOPE_KEY = "sonarlint-preference-scope"; + @Override + public Preferences getRemoteConfigurationPreferences(Project project) { + if (project == null) { + return getGlobalSettingsPreferences(); + } + return ProjectUtils.getPreferences(project, SonarLintRemoteProjectConfiguration.class, true); + } + @Override public Preferences getPreferences(Project project) { if (project == null) { diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java index 74765f9..89a03af 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImpl.java @@ -88,8 +88,17 @@ public final class SonarLintEngineImpl implements SonarLintEngine { private final List> configurationChanged = Collections.synchronizedList(new ArrayList<>()); private final Map pluginPaths = new HashMap<>(); private final Lookup lookup = Lookup.getDefault(); + private final Language[] languages; + /** + * Default constructor for lookup + */ public SonarLintEngineImpl() { + this(Language.values()); + } + + public SonarLintEngineImpl(Language[] languages) { + this.languages = languages; SonarLintDataManager sonarLintDataManager = getSonarLintDataManager(); pluginPaths.put("java", sonarLintDataManager.getInstalledFile("sonar/plugins/sonar-java-plugin-" + SONAR_JAVA_PLUGIN_VERSION + ".jar").toPath()); pluginPaths.put("javascript", sonarLintDataManager.getInstalledFile("sonar/plugins/sonar-javascript-plugin-" + SONAR_JAVASCRIPT_PLUGIN_VERSION + ".jar").toPath()); @@ -160,7 +169,7 @@ private void createInternalEngine(StandaloneSonarLintEngineImpl oldStandaloneSon List allPluginPaths = new ArrayList<>(allPlugins.values()); StandaloneGlobalConfiguration.Builder configBuilder = StandaloneGlobalConfiguration.builder() - .addEnabledLanguages(Language.values()) + .addEnabledLanguages(languages) .addPlugins(allPluginPaths.toArray(new Path[allPluginPaths.size()])); Optional nodeJSPathOptional = getNodeJSPath(); Optional nodeJSVersionOptional = getNodeJSVersion(); diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java index bfe4b98..3b2d42c 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java @@ -70,6 +70,7 @@ public final class SonarLintRemoteEngine { private static final String RUNTIME_NODE_JS_VERSION_PREFERENCE = "nodejs.version"; private final Clock clock = Clock.systemUTC(); private final Lookup lookup = Lookup.getDefault(); + private final Language[] languages; private final Map connectedSonarLintEngineImpls = Collections.synchronizedMap(new HashMap<>()); @@ -77,8 +78,16 @@ public final class SonarLintRemoteEngine { * Default constructor for Lookup */ public SonarLintRemoteEngine() { + this.languages = Language.values(); } - + + /** + * Constructor testing, reduce downloads (plugin, rules, ...) + */ + public SonarLintRemoteEngine(Language[] languages) { + this.languages = languages; + } + private String toKey(SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration) { return sonarLintRemoteProjectConfiguration.getProjectKey() + "-" + sonarLintRemoteProjectConfiguration.getOrganization() + "-" + @@ -139,13 +148,13 @@ private ConnectedSonarLintEngineImpl getConnectedSonarLintEngineImpl(SonarLintRe String sonarLintHome = System.getProperty("user.home") + File.separator + ".sonarlint4netbeans"; return connectedSonarLintEngineImpls.computeIfAbsent( sonarLintRemoteProjectConfiguration.getConnectionId(), - c -> + (String connectionId) -> new ConnectedSonarLintEngineImpl( createBuilder() - .setConnectionId(c) + .setConnectionId(connectionId) .setStorageRoot(Paths.get(sonarLintHome, "storage")) .setWorkDir(Paths.get(sonarLintHome, "work")) - .addEnabledLanguages(Language.values()) + .addEnabledLanguages(languages) .build() ) ); diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java index dc35f3a..7bba2d6 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java @@ -19,17 +19,18 @@ */ package com.github.philippefichet.sonarlint4netbeans.remote.configuration; +import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManager; import java.io.File; import java.util.Map; import java.util.Optional; import java.util.prefs.Preferences; import org.netbeans.api.project.Project; -import org.netbeans.api.project.ProjectUtils; import org.netbeans.libs.git.GitBranch; import org.netbeans.libs.git.GitException; import org.netbeans.libs.git.GitRepository; import org.netbeans.libs.git.progress.ProgressMonitor; import org.openide.filesystems.FileUtil; +import org.openide.util.Lookup; /** * @@ -54,7 +55,8 @@ public SonarLintRemoteProjectConfiguration(Project project, String connectionId, } public static SonarLintRemoteProjectConfiguration fromProject(Project project) { - Preferences preferences = ProjectUtils.getPreferences(project, SonarLintRemoteProjectConfiguration.class, true); + SonarLintDataManager sonarLintDataManager = Lookup.getDefault().lookup(SonarLintDataManager.class); + Preferences preferences = sonarLintDataManager.getRemoteConfigurationPreferences(project); return new SonarLintRemoteProjectConfiguration( project, preferences.get(PROP_CONNECTION_ID, null), @@ -66,6 +68,7 @@ public static SonarLintRemoteProjectConfiguration fromProject(Project project) { public static SonarLintRemoteProjectConfiguration fromProject(Project project, String connectionId, String projectKey, String organization) { File projectDir = FileUtil.toFile(project.getProjectDirectory()); + // TODO GitRepository instance = GitRepository.getInstance(projectDir); Map branches = null; try { @@ -82,7 +85,8 @@ public static SonarLintRemoteProjectConfiguration fromProject(Project project, S } public static void save(Project project, String sonarLintRemoteConnectionId, String projectKey, String organization) { - Preferences preferences = ProjectUtils.getPreferences(project, SonarLintRemoteProjectConfiguration.class, true); + SonarLintDataManager sonarLintDataManager = Lookup.getDefault().lookup(SonarLintDataManager.class); + Preferences preferences = sonarLintDataManager.getRemoteConfigurationPreferences(project); preferences.put(PROP_CONNECTION_ID, sonarLintRemoteConnectionId); preferences.put(PROP_PROJECT_KEY, projectKey); preferences.put(PROP_ORGANIZATION, organization); diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java index 0366686..fe9c54c 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintDataManagerMockedBuilder.java @@ -27,6 +27,7 @@ import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.netbeans.api.project.Project; +import org.openide.filesystems.FileUtil; /** * @@ -53,6 +54,24 @@ public SonarLintDataManagerMockedBuilder createPreferences(Project project) { Mockito.when(sonarLintDataManagerMocked.getPreferences(project)) .thenReturn(new SonarLintPreferencesForTesting()); + Mockito.when(sonarLintDataManagerMocked.getRemoteConfigurationPreferences(project)) + .thenReturn(new SonarLintPreferencesForTesting()); + return this; + } + + public SonarLintDataManagerMockedBuilder createPreferences(Project project, SonarLintProjectPreferenceScope scope) + { + createPreferences(project); + preferencesScope(project, scope); + return this; + } + + public SonarLintDataManagerMockedBuilder addFileToProject(Project project, File file) + { + Mockito.when(sonarLintDataManagerMocked.getProject(file)) + .thenReturn(Optional.of(project)); + Mockito.when(sonarLintDataManagerMocked.getProject(FileUtil.toFileObject(file))) + .thenReturn(Optional.of(project)); return this; } diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java index 15ed31f..bbd5594 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleType; /** @@ -54,6 +55,7 @@ static Arguments[] parametersForAnalyze() throws IOException Arguments.of( SonarLintEngineTestConfiguration.builder() .requirePlugin("java") + .enabledLanguages(Language.JAVA) .description("SonarLintFileDemo.java with rule java:S115 but without java:S122 and java:S1118 to check CODE_SMELL CRITICAL") .includeRules("java:S115") .excludeRules("java:S1220", "java:S1118") @@ -75,6 +77,7 @@ static Arguments[] parametersForAnalyze() throws IOException Arguments.of( SonarLintEngineTestConfiguration.builder() .requirePlugin("java") + .enabledLanguages(Language.JAVA) .description("NewClass.java with rule java:S1133 but without java:S1186, java:S1598, java:S100, java:S1134, java:S2168 and java:S115 to check CODE_SMELL INFO") .includeRules("java:S1133") .excludeRules("java:S1186", "java:S1598", "java:S100", "java:S1134", "java:S2168", "java:S115") @@ -96,6 +99,7 @@ static Arguments[] parametersForAnalyze() throws IOException Arguments.of( SonarLintEngineTestConfiguration.builder() .requirePlugin("java") + .enabledLanguages(Language.JAVA) .description("SonarLintFileDemo.java with rule java:S115 but without java:S1220 and S1118 rule with default parameters") .includeRules("java:S115") .excludeRules("java:S1220", "java:S1118") @@ -117,6 +121,7 @@ static Arguments[] parametersForAnalyze() throws IOException Arguments.of( SonarLintEngineTestConfiguration.builder() .requirePlugin("java") + .enabledLanguages(Language.JAVA) .description("SonarLintFileDemo.java with rule java:S115 but without java:S1220 and S1118 rule with custom parameters") .includeRules("java:S115") .excludeRules("java:S1220", "java:S1118") diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java index d19eba8..e4988db 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java @@ -34,6 +34,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleType; /** @@ -63,6 +64,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlint-example.js with rule javascript:S108 to check javascript plugin that require nodejs") .requirePlugin("javascript") + .enabledLanguages(Language.JS) .requireNodeJS() .excludeRules("javascript:S3504", "javascript:S3827", "javascript:S3504") .includeRules("javascript:S108") @@ -85,6 +87,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlint-example-with-global-variables.js with rule javascript:S3827 to check 3 issues from global variable declaring without extra properties \"sonar.javascript.globals\"") .requirePlugin("javascript") + .enabledLanguages(Language.JS) .requireNodeJS() .excludeRules("javascript:S3504") .includeRules("javascript:S3827") @@ -130,8 +133,9 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlint-example-with-global-variables.js with rule javascript:S3827 to check one issue from global variable declaring in extra properties \"sonar.javascript.globals\" for \"globalVariables,api\"") .requirePlugin("javascript") + .enabledLanguages(Language.JS) .requireNodeJS() - .excludeRules("javascript:S3504") + .excludeRules("javascript:S3504") .includeRules("javascript:S3827") .addClientInputFile(new File("./src/test/resources/sonarlint-example-with-global-variables.js")) .addExtraProperty("sonar.javascript.globals", "globalVariables,api", SonarLintEngine.GLOBAL_SETTINGS_PROJECT) @@ -155,6 +159,7 @@ public static Arguments[] parametersForAnalyze() throws IOException .description("sonarlint-example-with-global-variables.js with rule javascript:S3827 to check two issues from global variable declaring with extra properties \"sonar.javascript.globals\" for \"AapiI\"") .requirePlugin("javascript") .requireNodeJS() + .enabledLanguages(Language.JS) .excludeRules("javascript:S3504") .includeRules("javascript:S3827") .addClientInputFile(new File("./src/test/resources/sonarlint-example-with-global-variables.js")) @@ -189,6 +194,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlint-example.css with rule css:S1116 to check one issue on line \"4\"") .requirePlugin("javascript") + .enabledLanguages(Language.JS) .requireNodeJS() .includeRules("css:S1116") .addClientInputFile(new File("./src/test/resources/sonarlint-example.css")) diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java index c3a0563..f1e1438 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleType; /** @@ -57,6 +58,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlin-example.php with rule php:S101 but without php:S1105 to check php plugin") .requirePlugin("php") + .enabledLanguages(Language.PHP) .excludeRules("php:S1105", "php:S1808", "php:S1779") .includeRules("php:S101") .addClientInputFile(new File("./src/test/resources/sonarlint-example.php")) diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java index a0f62a8..762511c 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTest.java @@ -34,6 +34,7 @@ import org.mockito.Mockito; import org.netbeans.api.project.Project; import org.netbeans.spi.project.ProjectManagerImplementation; +import org.sonarsource.sonarlint.core.commons.Language; /** * @@ -66,7 +67,7 @@ public void getRuleParameter() throws MalformedURLException, BackingStoreExcepti String parameterName = "max"; String parameterValueOnProjectScope = "5"; String parameterValueOnGlobalScope = "4"; - SonarLintEngineImpl sonarLintEngine = new SonarLintEngineImpl(); + SonarLintEngineImpl sonarLintEngine = new SonarLintEngineImpl(new Language[] {Language.JAVA}); sonarLintEngine.waitingInitialization(); sonarLintEngine.getPreferences(SonarLintEngine.GLOBAL_SETTINGS_PROJECT).removeNode(); sonarLintEngine.setRuleParameter(ruleKey, parameterName, parameterValueOnProjectScope, mockedProjectWithProjectScope); @@ -132,7 +133,7 @@ public void getMergedExtraProperties( Map exptectedProperties ) { // Given - SonarLintEngineImpl sonarLintEngine = new SonarLintEngineImpl(); + SonarLintEngineImpl sonarLintEngine = new SonarLintEngineImpl(new Language[] {}); sonarLintEngine.waitingInitialization(); sonarLintEngine.setExtraProperties(actualGlobalProperties, SonarLintEngine.GLOBAL_SETTINGS_PROJECT); sonarLintEngine.setExtraProperties(actualProjectProperties, project); diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java index 43c52aa..8b42293 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java @@ -51,7 +51,7 @@ private SonarLintEngineImplTestUtils() { public static void analyzeTesting(SonarLintEngineTestConfiguration testConfiguration, List expectedIssue) throws BackingStoreException, IOException { - SonarLintEngineImpl sonarLintEngine = new SonarLintEngineImpl(); + SonarLintEngineImpl sonarLintEngine = new SonarLintEngineImpl(testConfiguration.getEnabledLanguages()); sonarLintEngine.waitingInitialization(); if (testConfiguration.isRequireNodeJS()) { SonarLintTestUtils.installNodeJS(); diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java index 266ef39..407e52c 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleType; /** @@ -57,6 +58,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlin-example.php with rule php:S101 but without php:S1105 to check php plugin") .requirePlugin("web") + .enabledLanguages(Language.HTML) .includeRules("Web:BoldAndItalicTagsCheck", "Web:S5254") .addClientInputFile(new File("./src/test/resources/sonarlint-example.html")) .build(), diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java index b39475a..4714539 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.params.provider.MethodSource; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleType; /** @@ -57,6 +58,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlin-example.php with rule php:S101 but without php:S1105 to check php plugin") .requirePlugin("xml") + .enabledLanguages(Language.XML) .includeRules("xml:S1134") .addClientInputFile(new File("./src/test/resources/sonarlint-example.xml")) .build(), diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java index 0e49acc..eb4f2c2 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineTestConfiguration.java @@ -30,6 +30,7 @@ import java.util.Map; import org.netbeans.api.project.Project; import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleKey; /** @@ -44,6 +45,7 @@ public final class SonarLintEngineTestConfiguration { private final List ruleParameters; private final Map> extraProperties; private final List requirePlugin; + private final Language[] enabledLanguages; private final boolean requireNodeJS; @@ -56,6 +58,7 @@ private SonarLintEngineTestConfiguration(Builder builder) { this.requireNodeJS = builder.requireNodeJS; this.extraProperties = builder.extraProperties; this.requirePlugin = builder.requirePlugin; + this.enabledLanguages = builder.enabledLanguages; } public List getExcludedRules() { @@ -86,6 +89,10 @@ public Map> getExtraProperties() { return extraProperties; } + public Language[] getEnabledLanguages() { + return enabledLanguages; + } + @Override public String toString() { return description; @@ -128,6 +135,7 @@ public static final class Builder { private final Map> extraProperties = new HashMap<>(); private final List requirePlugin = new ArrayList<>(); private boolean requireNodeJS = false; + private Language[] enabledLanguages = Language.values(); public Builder description(String description) { this.description = description; @@ -181,6 +189,11 @@ public Builder requirePlugin(String pluginKey) { return this; } + public Builder enabledLanguages(Language ... enabledLanguages) { + this.enabledLanguages = enabledLanguages; + return this; + } + public SonarLintEngineTestConfiguration build() { return new SonarLintEngineTestConfiguration(this); } diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java index 65a9809..cb0fed5 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintEngineEnableLanguage; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; import com.github.philippefichet.sonarlint4netbeans.treenode.SonarLintAnalyzerRootNode; @@ -68,6 +69,7 @@ import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneRuleDetails; import org.sonarsource.sonarlint.core.client.api.standalone.StandaloneRuleParam; import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; import org.sonarsource.sonarlint.core.commons.RuleKey; import org.sonarsource.sonarlint.core.commons.RuleType; import org.sonarsource.sonarlint.core.commons.Version; @@ -82,38 +84,34 @@ class SonarLintUtilsTest { @Nested class ProjectBased { - private final Project mockedProjectWithProjectScope = Mockito.mock(Project.class); - private final Project mockedSecondProjectWithGlobalScope = Mockito.mock(Project.class); - private final Project mockedThirdProjectWithGlobalScope = Mockito.mock(Project.class); - private final Project mockedFirstProjectWithGlobalScope = Mockito.mock(Project.class); + private final Project mockedProjectWithProjectScope = new ProjectMockedBuilder().build(); + private final Project mockedSecondProjectWithGlobalScope = new ProjectMockedBuilder().build(); + private final Project mockedThirdProjectWithGlobalScope = new ProjectMockedBuilder().build(); + private final Project mockedFirstProjectWithGlobalScope = new ProjectMockedBuilder().build(); + private final Project sonarlint4netbeansSampleMavenProject = new ProjectMockedBuilder() + .projectDirectory(new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject")) + .build(); @RegisterExtension private final SonarLintLookupMockedExtension lookupExtension = SonarLintLookupMockedExtension.builder() .logCall() - .mockLookupMethodInstanceWith(SonarLintEngine.class, () -> { - SonarLintEngineImpl engine = new SonarLintEngineImpl(); - engine.waitingInitialization(); - return engine; - }) .mockLookupMethodWith(ProjectManagerImplementation.class, Mockito.mock(ProjectManagerImplementation.class)) .mockLookupMethodWith(SonarLintOptions.class, Mockito.mock(SonarLintOptions.class)) .mockLookupMethodWith( SonarLintDataManager.class, new SonarLintDataManagerMockedBuilder() - .createPreferences(mockedProjectWithProjectScope) - .preferencesScope(mockedProjectWithProjectScope, SonarLintProjectPreferenceScope.PROJECT) - .createPreferences(mockedFirstProjectWithGlobalScope) - .preferencesScope(mockedFirstProjectWithGlobalScope, SonarLintProjectPreferenceScope.GLOBAL) - .createPreferences(mockedSecondProjectWithGlobalScope) - .preferencesScope(mockedSecondProjectWithGlobalScope, SonarLintProjectPreferenceScope.GLOBAL) - .createPreferences(mockedThirdProjectWithGlobalScope) - .preferencesScope(mockedThirdProjectWithGlobalScope, SonarLintProjectPreferenceScope.GLOBAL) + .createPreferences(mockedProjectWithProjectScope, SonarLintProjectPreferenceScope.PROJECT) + .createPreferences(mockedFirstProjectWithGlobalScope, SonarLintProjectPreferenceScope.GLOBAL) + .createPreferences(mockedSecondProjectWithGlobalScope, SonarLintProjectPreferenceScope.GLOBAL) + .createPreferences(mockedThirdProjectWithGlobalScope, SonarLintProjectPreferenceScope.GLOBAL) .preferencesScope(SonarLintEngine.GLOBAL_SETTINGS_PROJECT, SonarLintProjectPreferenceScope.GLOBAL) + .createPreferences(sonarlint4netbeansSampleMavenProject, SonarLintProjectPreferenceScope.REMOTE) .build() ).build(); @Test @DisplayName("Analyze hierarchical tree used in \"Analyze with Sonarlint\"") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void likeAnalyzeWithSonarlint() throws IOException, BackingStoreException { // first step, check all issue in file List actualIssues = new ArrayList<>(); @@ -249,6 +247,7 @@ void likeAnalyzeWithSonarlint() throws IOException, BackingStoreException { @Test @DisplayName("Analyze with custom rule parameter value on project with global scope") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void ruleParameterChangedOnProjectWithGlobalScope() throws IOException, BackingStoreException { SonarLintDataManager sonarlintDataMangerMocked = lookupExtension.lookupMocked(SonarLintDataManager.class).get(); SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); @@ -303,6 +302,7 @@ void ruleParameterChangedOnProjectWithGlobalScope() throws IOException, BackingS @Test @DisplayName("Analyze with custom rule parameter value on project") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void ruleParameterChangedOnProject() throws IOException, BackingStoreException { SonarLintDataManager sonarlintDataMangerMocked = lookupExtension.lookupMocked(SonarLintDataManager.class).get(); SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); @@ -351,6 +351,7 @@ void ruleParameterChangedOnProject() throws IOException, BackingStoreException { @Test @DisplayName("Check custom rule parameter value from extractRuleParameters on project with global scope") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void extractRuleParametersWithCustomValueOnProjectWithGlobalScope() throws BackingStoreException, MalformedURLException { SonarLintEngine sonarLintEngine = new SonarLintEngineImpl(); SonarLintTestUtils.cleanSonarLintEngine(sonarLintEngine); @@ -386,6 +387,7 @@ void extractRuleParametersWithCustomValueOnProjectWithGlobalScope() throws Backi @Test @DisplayName("Analyze with extra properties on project") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void extraPropertiesOnProject() throws IOException, BackingStoreException { String commonExtraPropertyName = "sonar.java.source"; SonarLintDataManager sonarlintDataMangerMocked = lookupExtension.lookupMocked(SonarLintDataManager.class).get(); @@ -473,6 +475,7 @@ void extraPropertiesOnProject() throws IOException, BackingStoreException { @Test @DisplayName("Check custom rule parameter value from extractRuleParameters") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void extractRuleParametersWithCustomValue() throws BackingStoreException { SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); String ruleKeyString = "java:S115"; @@ -487,6 +490,7 @@ void extractRuleParametersWithCustomValue() throws BackingStoreException { @Test @DisplayName("Check default rule parameter value from extractRuleParameters") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void extractRuleParametersWithDefaultValue() throws BackingStoreException { SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); String ruleKeyString = "java:S115"; @@ -500,6 +504,7 @@ void extractRuleParametersWithDefaultValue() throws BackingStoreException { @Test @DisplayName("Analyze hierarchical tree used in \"Analyze with Sonarlint\" with a custom rule parameter value") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void likeAnalyzeWithSonarlintWithParameter() throws BackingStoreException, IOException { SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); sonarLintEngine.getAllRuleDetails().forEach(ruleKey -> sonarLintEngine.excludeRuleKey(RuleKey.parse(ruleKey.getKey()), SonarLintEngine.GLOBAL_SETTINGS_PROJECT)); @@ -585,6 +590,7 @@ void likeAnalyzeWithSonarlintWithParameter() throws BackingStoreException, IOExc @Test @DisplayName("Analyze with custom rule parameter value") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void ruleParameterChanged() throws BackingStoreException, IOException { SonarLintEngine sonarLintEngine = SonarLintTestUtils.getCleanSonarLintEngine(); String ruleKeyString = "java:S115"; @@ -602,6 +608,7 @@ void ruleParameterChanged() throws BackingStoreException, IOException { @Test @DisplayName("Analyze with custom rule parameter value to check ${projectDir}") + @SonarLintEngineEnableLanguage(languages = Language.JAVA) void analyseFilesOnTwoProjectWithProjectDirInProperties( @TempDir File projectDir1, @TempDir File projectDir2, diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintEngineEnableLanguage.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintEngineEnableLanguage.java new file mode 100644 index 0000000..c30fb27 --- /dev/null +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintEngineEnableLanguage.java @@ -0,0 +1,37 @@ +/* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import org.sonarsource.sonarlint.core.commons.Language; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface SonarLintEngineEnableLanguage { + + Language[] languages(); +} diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java index 81ad6bd..89fd410 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/junit/jupiter/extension/SonarLintLookupMockedExtension.java @@ -20,8 +20,12 @@ package com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension; import com.github.philippefichet.sonarlint4netbeans.Predicates; +import com.github.philippefichet.sonarlint4netbeans.SonarLintEngine; +import com.github.philippefichet.sonarlint4netbeans.SonarLintEngineImpl; import com.github.philippefichet.sonarlint4netbeans.assertj.SonarLintArgumentMatchers; +import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintRemoteEngine; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -38,6 +42,7 @@ import org.openide.util.Lookup; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.sonarsource.sonarlint.core.commons.Language; /** * @@ -118,18 +123,22 @@ private void init() }); } + mockLookupMethodInstance(lookupMethodInstance); + } + + private void mockLookupMethodInstance(Map, Supplier> lookupMethodInstance) { if (!lookupMethodInstance.isEmpty()) { Map, Object> instances = new HashMap<>(); lookupMethodInstance.forEach( (Class clazz, Supplier supplier) -> { - Mockito.when(mockedLookup.lookup(clazz)) + Mockito.when(mockedLookup.lookup(clazz)) .thenAnswer( (InvocationOnMock iom) -> { if (logCall) { LOG.debug("defaultLookup.lookup(Class) for an specific instance called with \"{}\"", clazz); } return instances.computeIfAbsent(clazz, (Class cls) -> supplier.get()); - }); + }); } ); } @@ -137,6 +146,20 @@ private void init() @Override public void interceptTestMethod(Invocation invocation, ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext) throws Throwable { + SonarLintEngineEnableLanguage annotation = invocationContext.getExecutable().getAnnotation(SonarLintEngineEnableLanguage.class); + Language[] languages = annotation == null ? Language.values() : annotation.languages(); + LOG.info("Language enabled: \"{}\"", Arrays.toString(languages)); + Map, Supplier> lookupMethodInstanceEngines = new HashMap<>(); + lookupMethodInstanceEngines.put(SonarLintEngine.class, () -> { + SonarLintEngineImpl engine = new SonarLintEngineImpl(languages); + engine.waitingInitialization(); + return engine; + }); + lookupMethodInstanceEngines.put(SonarLintRemoteEngine.class, () -> { + SonarLintRemoteEngine engine = new SonarLintRemoteEngine(languages); + return engine; + }); + mockLookupMethodInstance(lookupMethodInstanceEngines); executeInMockedLookup(() -> { try { InvocationInterceptor.super.interceptTestMethod( diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java new file mode 100644 index 0000000..c7e77e7 --- /dev/null +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java @@ -0,0 +1,128 @@ +/* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote; + +import com.github.philippefichet.sonarlint4netbeans.DefaultIssueTestImpl; +import com.github.philippefichet.sonarlint4netbeans.ProjectMockedBuilder; +import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManager; +import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManagerMockedBuilder; +import com.github.philippefichet.sonarlint4netbeans.SonarLintUtils; +import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; +import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfigurationManagement; +import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; +import com.github.philippefichet.sonarlint4netbeans.remote.synchronization.TaskWrapper; +import java.io.File; +import java.io.IOException; +import java.util.List; +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.mockito.Mockito; +import org.netbeans.api.project.Project; +import org.openide.filesystems.FileUtil; +import org.openide.util.Lookup; +import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; +import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.Language; +import org.sonarsource.sonarlint.core.commons.RuleType; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +@EnabledIfSystemProperty( + named = "sonarlint4netbeans.test.remote.project-maven1.token", + matches = "[a-f0-9]+", + disabledReason = "Disabled because require token to check remote issue on sample project" +) +public class SonarLintRemoteEngineTest { + + private final Project sonarlint4netbeansSampleMavenProject = new ProjectMockedBuilder() + .projectDirectory(new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main")) + .build(); + + private final File sonarlint4netbeansSampleMavenProjectNewClass = + new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java"); + + @RegisterExtension + SonarLintLookupMockedExtension sonarLintLookupMockedExtension = SonarLintLookupMockedExtension.builder() + .logCall() + .mockLookupMethodWith( + SonarLintDataManager.class, + new SonarLintDataManagerMockedBuilder() + .createPreferences(sonarlint4netbeansSampleMavenProject) + .preferencesScope(sonarlint4netbeansSampleMavenProject, SonarLintProjectPreferenceScope.REMOTE) + .addFileToProject(sonarlint4netbeansSampleMavenProject, sonarlint4netbeansSampleMavenProjectNewClass) + .build() + ).mockLookupMethodWith(Project.class, Mockito.mock(Project.class)) + .mockLookupMethodWith(SonarLintRemoteConnectionConfigurationManagement.class, Mockito.mock(SonarLintRemoteConnectionConfigurationManagement.class)) + .build(); + + @Test + public void remote() throws InterruptedException, IOException { + SonarLintRemoteConnectionConfigurationManagement sonarLintRemoteConnectionConfigurationManagement = Lookup.getDefault().lookup(SonarLintRemoteConnectionConfigurationManagement.class); + String connectionId = "testing-connection-id-sonarcloud"; + String projectKey = "philippefichet_sonarlint4netbeans-sample-mavenproject"; + String branchName = "master"; + String baseURL = "https://sonarcloud.io"; + boolean isSonarCloud = true; + String organization = "philippefichet"; + String login = System.getProperty("sonarlint4netbeans.test.remote.project-maven1.token"); + SonarLintRemoteConnectionConfiguration sonarLintRemoteConnectionConfiguration = new SonarLintRemoteConnectionConfiguration( + connectionId, + baseURL, + isSonarCloud + ); + Mockito.when(sonarLintRemoteConnectionConfigurationManagement.getAuthTokenFromConnectionId(connectionId)) + .thenReturn(Optional.of(login)); + Mockito.when(sonarLintRemoteConnectionConfigurationManagement.getSonarLintConnectionConfigurationFromConnectionId(connectionId)) + .thenReturn(Optional.of(sonarLintRemoteConnectionConfiguration)); + + SonarLintRemoteEngine remoteEngine = new SonarLintRemoteEngine(new Language[] {Language.JAVA}); + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration = new SonarLintRemoteProjectConfiguration( + sonarlint4netbeansSampleMavenProject, + connectionId, + projectKey, + organization, + branchName + ); + SonarLintRemoteProjectConfiguration.save(sonarlint4netbeansSampleMavenProject, connectionId, projectKey, organization); + TaskWrapper sync = remoteEngine.launchResyncTask( + sonarLintRemoteProjectConfiguration + ); + sync.getTask().waitFinished(30_000); + List issues = SonarLintUtils.analyze(FileUtil.toFileObject(sonarlint4netbeansSampleMavenProjectNewClass), null); + Assertions.assertThat(issues) + .extracting(DefaultIssueTestImpl::toTuple) + .containsAnyOf( + new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S2629") + .startLine(80) + .endLine(80) + .buildTuple() + ); + } +} diff --git a/src/test/resources/logging.properties b/src/test/resources/logging.properties index cf8ee15..7099a1a 100644 --- a/src/test/resources/logging.properties +++ b/src/test/resources/logging.properties @@ -1,9 +1,9 @@ handlers=java.util.logging.ConsoleHandler .level=INFO -java.util.logging.ConsoleHandler.level=FINEST +java.util.logging.ConsoleHandler.level=INFO java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter # String.format(format, date, source, logger, level, message, thrown); # https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html # %[argument_index$][flags][width][.precision]conversion java.util.logging.SimpleFormatter.format=| %1$tc | %2$s | %3$s | %4$5s | %5$s |%n -com.github.philippefichet.sonarlint4netbeans.level=FINEST +com.github.philippefichet.sonarlint4netbeans.level=INFO diff --git a/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java b/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java new file mode 100644 index 0000000..28777b6 --- /dev/null +++ b/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java @@ -0,0 +1,83 @@ +/* + * sonarlint4netbeans-sample-mavenproject: Sample for SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.mycompany.mavenproject1; + +import java.nio.file.Path; + +public class NewClass { + private static String resource; + public static final String const_convition_violation = "TEST"; + + /** + * + * @deprecated + */ + @Deprecated + public void deprecatedMethod() {} + + public void MethodName_Convention_Violation() {} + + + // FIXME test + public static String getInstance() { + if (resource == null) { + synchronized (NewClass.class) { + if (resource == null) + resource = ""; + } + } + return resource; + } + + public static void lambdaTest() + { + String t = "toto"; + Runnable r = () -> { + for (int i = 0; i < 10; i++) { + System.out.println(t.trim()); + } + }; + new Thread(r).start(); + } + + public static void tooManyParameter(int param1, int param2, int param3, String param4, long param5, int param6, int param7, int param8, String param9) { + System.out.println("test"); + } + + /** + * Use "sonar.java.source=8" property to detected this issue + */ + public static void checkS3725WithExtraProperties() { + Path myPath = null; + if(java.nio.file.Files.exists(myPath)) { // Noncompliant + // do something + } + } + + /** + * Use "sonar.java.libraries=${projectDir}/target/lib/*.jar" and + * java:S2629 must be enabled and slf4j-api-1.7.36 copied in target/lib + * to show an issue + * Or cloud analyse + */ + public static void checkJavaS2629WithExtraPropertiesAndProjectDir(String arg1) { + org.slf4j.LoggerFactory.getLogger("Testing").debug("message: " + arg1); + } +} From 707f70176448248d1666a49e1e83431f302a2103 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 21 Dec 2023 18:10:37 +0100 Subject: [PATCH 10/17] remove test reporter on MacOS --- .github/workflows/build-on-macos.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/build-on-macos.yml b/.github/workflows/build-on-macos.yml index 7a1dc7d..9392e38 100644 --- a/.github/workflows/build-on-macos.yml +++ b/.github/workflows/build-on-macos.yml @@ -25,13 +25,3 @@ jobs: - name: Test with Maven run: mvn -Ddependency-check.skip=true -DhasNodeJSRuntime clean test timeout-minutes: 10 - - name: Test Report - uses: dorny/test-reporter@v1 - if: success() || failure() # run this step even if previous step failed - with: - # Name of the check run which will be created - name: JUnit Tests - # Path to test results - path: target/surefire-reports/*.xml - # Format of test results - reporter: java-junit From 7c91a9659082800d6ab717460f3eb70622d3be47 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 21 Dec 2023 22:22:03 +0100 Subject: [PATCH 11/17] fix tests --- pom.xml | 34 +++++-------------- ...narLintEngineImplJavascriptPluginTest.java | 2 +- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index 0b568b6..29b64ff 100644 --- a/pom.xml +++ b/pom.xml @@ -85,33 +85,15 @@ maven-surefire-plugin 3.2.2 - - - java.util.logging.config.file - ./src/test/resources/logging.properties - - - file.encoding - UTF-8 - - - junit.jupiter.extensions.autodetection.enabled - true - - - hasNodeJSRuntime - ${hasNodeJSRuntime} - - - sonarlint4netbeans.test.skip.javascript - ${sonarlint4netbeans.test.skip.javascript} - + + ./src/test/resources/logging.properties + UTF-8 + true + ${hasNodeJSRuntime} + ${sonarlint4netbeans.test.skip.javascript} - - sonarlint4netbeans.test.remote.project-maven1.token - ${sonarlint4netbeans.test.remote.project-maven1.token} - - + ${sonarlint4netbeans.test.remote.project-maven1.token} + diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java index e4988db..9bf776a 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java @@ -194,7 +194,7 @@ public static Arguments[] parametersForAnalyze() throws IOException SonarLintEngineTestConfiguration.builder() .description("sonarlint-example.css with rule css:S1116 to check one issue on line \"4\"") .requirePlugin("javascript") - .enabledLanguages(Language.JS) + .enabledLanguages(Language.CSS) .requireNodeJS() .includeRules("css:S1116") .addClientInputFile(new File("./src/test/resources/sonarlint-example.css")) From b81a97873cd66aced186d64002a1085586eab04b Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Sat, 23 Dec 2023 21:10:42 +0100 Subject: [PATCH 12/17] Local change processing for sonarcloud issues --- .../sonarlint4netbeans/FSClientInputFile.java | 18 +++ .../sonarlint4netbeans/SonarLintUtils.java | 118 +++++++++--------- .../remote/SourceLineHashesComputer.java | 67 ++++++++++ .../SonarLintIssueWrapperForServerIssue.java | 47 ++++--- .../remote/SonarLintRemoteEngineTest.java | 71 ++++++++++- .../com/mycompany/mavenproject1/NewClass.java | 84 +++++++++++++ .../com/mycompany/mavenproject1/NewClass.java | 1 - 7 files changed, 325 insertions(+), 81 deletions(-) create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SourceLineHashesComputer.java create mode 100644 src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master-with-local-change/src/main/java/com/mycompany/mavenproject1/NewClass.java rename src/test/samples/sonarlint4netbeans-sample-mavenproject/{branch-main => branch-master}/src/main/java/com/mycompany/mavenproject1/NewClass.java (99%) diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java index 4d99986..6340d45 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/FSClientInputFile.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.remote.SourceLineHashesComputer; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -27,6 +28,7 @@ import java.nio.file.Path; import java.util.ArrayList; import java.util.List; +import org.openide.util.Exceptions; import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; /** @@ -41,6 +43,7 @@ public class FSClientInputFile implements ClientInputFile { private final Charset encoding; private final String content; private final List clientInputFileURIEvents = new ArrayList<>(); + private SourceLineHashesComputer sourceLineHashesComputer; public FSClientInputFile(String content, Path path, String relativePath, boolean isTest, Charset encoding) { this.content = content; @@ -105,6 +108,21 @@ private void consumePathURI() { } } + public List getLineHashes() { + if (sourceLineHashesComputer == null) { + try { + String[] split = contents().split("\n"); + sourceLineHashesComputer = new SourceLineHashesComputer(split.length); + for (String line : split) { + sourceLineHashesComputer.addLine(line); + } + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + return sourceLineHashesComputer.getLineHashes(); + } + @Override public String toString() { return "FSClientInputFile{" + "path=" + path + ", relativePath=" + relativePath + ", isTest=" + isTest + ", encoding=" + encoding + '}'; diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java index 71576ff..e24ee89 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java @@ -65,7 +65,6 @@ import org.sonarsource.nodejs.NodeCommandBuilderImpl; import org.sonarsource.nodejs.NodeCommandException; import org.sonarsource.sonarlint.core.analysis.api.AnalysisResults; -import org.sonarsource.sonarlint.core.analysis.api.ClientInputFile; import org.sonarsource.sonarlint.core.client.api.common.RuleDetails; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; import org.sonarsource.sonarlint.core.client.api.common.analysis.IssueListener; @@ -268,74 +267,20 @@ public static List analyze(FileObject fileObject, String contentToAnalyze Path path = project == null ? toFile.getParentFile().toPath() : FileUtil.toFile(project.getProjectDirectory()).toPath(); - List clientInputFiles = new ArrayList<>(); boolean applyTestRules = useTestRules && dataManager.isTest(toFile); String relativizeToFile = path.relativize(toFile.toPath()).toString(); - clientInputFiles.add(new FSClientInputFile( + FSClientInputFile clientInputFile = new FSClientInputFile( contentToAnalyze == null ? new String(Files.readAllBytes(toFile.toPath())) : contentToAnalyze, toFile.toPath().toAbsolutePath(), relativizeToFile, applyTestRules, - FileEncodingQuery.getEncoding(fileObject)) + FileEncodingQuery.getEncoding(fileObject) ); SonarLintProjectPreferenceScope preferencesScope = dataManager.getPreferencesScope(project); String sonarLintHome = System.getProperty("user.home") + File.separator + ".sonarlint4netbeans"; if (preferencesScope == SonarLintProjectPreferenceScope.REMOTE) { - SonarLintRemoteEngine remoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); - SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); - ConnectedAnalysisConfiguration build = ConnectedAnalysisConfiguration.builder() - .setProjectKey(sonarLintRemoteProjectConfiguration.getProjectKey()) - .addInputFiles(clientInputFiles) - .setBaseDir(new File(sonarLintHome).toPath()) - // TODO Remove dependency with sonarLintEngine - .putAllExtraProperties(getMergedExtraPropertiesAndReplaceVariables(sonarLintEngine, project)) - .build(); - List listener = new ArrayList<>(); - AnalysisResults remoteAnalyze = remoteEngine.analyze( - sonarLintRemoteProjectConfiguration, - build, - listener::add, - (String formattedMessage, ClientLogOutput.Level level) -> { - System.out.println(level + " | " + formattedMessage); - }, - new ClientProgressMonitor() { - @Override - public boolean isCanceled() { - return false; - } - - @Override - public void setMessage(String msg) { - LOG.info("ClientProgressMonitor.setMessage(\"" + msg + "\")"); - } - - @Override - public void setFraction(float fraction) { - LOG.info("ClientProgressMonitor.setFraction(" + fraction + ")"); - } - - @Override - public void setIndeterminate(boolean indeterminate) { - LOG.info("ClientProgressMonitor.setIndeterminate(" + indeterminate + ")"); - } - } - ); - - List serverIssues = remoteEngine.getServerIssues(sonarLintRemoteProjectConfiguration, relativizeToFile); - serverIssues.stream() - .map( - s -> - new SonarLintIssueWrapperForServerIssue( - clientInputFiles.get(0), - s, - sonarLintEngine.getRuleDetails(s.getRuleKey()) - ) - ) - .forEach(listener::add); - LOG.fine(() -> "Analyze (Remote) result for file \"" + fileObject.getPath() + "\" : " + remoteAnalyze); - - return listener; + return analyzeRemote(sonarLintEngine, project, clientInputFile, sonarLintHome); } Project projectForRules = SonarLintDataManagerUtils.getProjectForAnalyse(dataManager, fileObject); @@ -346,7 +291,7 @@ public void setIndeterminate(boolean indeterminate) { StandaloneAnalysisConfiguration standaloneAnalysisConfiguration = StandaloneAnalysisConfiguration.builder() .setBaseDir(new File(sonarLintHome).toPath()) - .addInputFiles(clientInputFiles) + .addInputFiles(clientInputFile) .addExcludedRules(excludedRules) .addIncludedRules(includedRules) .addRuleParameters(sonarLintEngine.getRuleParameters(projectForRules)) @@ -367,6 +312,61 @@ public void setIndeterminate(boolean indeterminate) { return issues; } + private static List analyzeRemote(SonarLintEngine sonarLintEngine, Project project, FSClientInputFile clientInputFile, String sonarLintHome) { + SonarLintRemoteEngine remoteEngine = Lookup.getDefault().lookup(SonarLintRemoteEngine.class); + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration = SonarLintRemoteProjectConfiguration.fromProject(project); + ConnectedAnalysisConfiguration build = ConnectedAnalysisConfiguration.builder() + .setProjectKey(sonarLintRemoteProjectConfiguration.getProjectKey()) + .addInputFiles(clientInputFile) + .setBaseDir(new File(sonarLintHome).toPath()) + .build(); + List listener = new ArrayList<>(); + AnalysisResults remoteAnalyze = remoteEngine.analyze( + sonarLintRemoteProjectConfiguration, + build, + listener::add, + (String formattedMessage, ClientLogOutput.Level level) -> { + System.out.println(level + " | " + formattedMessage); + }, + new ClientProgressMonitor() { + @Override + public boolean isCanceled() { + return false; + } + + @Override + public void setMessage(String msg) { + LOG.info("ClientProgressMonitor.setMessage(\"" + msg + "\")"); + } + + @Override + public void setFraction(float fraction) { + LOG.info("ClientProgressMonitor.setFraction(" + fraction + ")"); + } + + @Override + public void setIndeterminate(boolean indeterminate) { + LOG.info("ClientProgressMonitor.setIndeterminate(" + indeterminate + ")"); + } + } + ); + + List serverIssues = remoteEngine.getServerIssues(sonarLintRemoteProjectConfiguration, clientInputFile.relativePath()); + serverIssues.stream() + .map( + s -> + new SonarLintIssueWrapperForServerIssue( + clientInputFile, + s, + // TODO replace by a sonarcloud/sonarqube rules store + sonarLintEngine.getRuleDetails(s.getRuleKey()) + ) + ) + .forEach(listener::add); + LOG.fine(() -> "Analyze (Remote) result for file \"" + clientInputFile.uri() + "\" : " + remoteAnalyze); + return listener; + } + /** * Retrive stylesheet for HTML rule detail description * @param sonarLintOptions SonarLint global integration option used to retrieve the stylesheet to apply diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SourceLineHashesComputer.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SourceLineHashesComputer.java new file mode 100644 index 0000000..ee3019d --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SourceLineHashesComputer.java @@ -0,0 +1,67 @@ +/* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.remote; + +import static java.nio.charset.StandardCharsets.UTF_8; +import java.security.MessageDigest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import org.sonarsource.sonarlint.shaded.org.apache.commons.codec.binary.Hex; +import org.sonarsource.sonarlint.shaded.org.apache.commons.codec.digest.DigestUtils; +import org.sonarsource.sonarlint.shaded.org.apache.commons.lang.StringUtils; + +/** + * Copied from + * https://github.com/SonarSource/sonarqube/blob/master/sonar-core/src/main/java/org/sonar/core/hash/SourceLineHashesComputer.java + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public class SourceLineHashesComputer { + + private final MessageDigest md5Digest = DigestUtils.getMd5Digest(); + private final List lineHashes; + + public SourceLineHashesComputer() { + this.lineHashes = new ArrayList<>(); + } + + public SourceLineHashesComputer(int expectedLineCount) { + this.lineHashes = new ArrayList<>(expectedLineCount); + } + + public void addLine(String line) { + Objects.requireNonNull(line, "line can not be null"); + lineHashes.add(computeHash(line)); + } + + public List getLineHashes() { + return Collections.unmodifiableList(lineHashes); + } + + private String computeHash(String line) { + String reducedLine = StringUtils.replaceChars(line, "\t ", ""); + if (reducedLine.isEmpty()) { + return ""; + } + return Hex.encodeHexString(md5Digest.digest(reducedLine.getBytes(UTF_8))); + } +} \ No newline at end of file diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java index 178b069..06fba2b 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans.remote.wrapper; +import com.github.philippefichet.sonarlint4netbeans.FSClientInputFile; import java.util.Collections; import java.util.List; import java.util.Map; @@ -34,7 +35,9 @@ import org.sonarsource.sonarlint.core.commons.RuleType; import org.sonarsource.sonarlint.core.commons.SoftwareQuality; import org.sonarsource.sonarlint.core.commons.TextRange; +import org.sonarsource.sonarlint.core.commons.TextRangeWithHash; import org.sonarsource.sonarlint.core.commons.VulnerabilityProbability; +import org.sonarsource.sonarlint.core.serverconnection.issues.FileLevelServerIssue; import org.sonarsource.sonarlint.core.serverconnection.issues.LineLevelServerIssue; import org.sonarsource.sonarlint.core.serverconnection.issues.RangeLevelServerIssue; import org.sonarsource.sonarlint.core.serverconnection.issues.ServerIssue; @@ -46,13 +49,37 @@ public class SonarLintIssueWrapperForServerIssue implements Issue { private final ServerIssue serverIssue; - private final ClientInputFile clientInputFile; + private final FSClientInputFile clientInputFile; private final Optional ruleDetails; + private final Integer startLine; + private final Integer endLine; - public SonarLintIssueWrapperForServerIssue(ClientInputFile clientInputFile, ServerIssue serverIssue, Optional ruleDetails) { + public SonarLintIssueWrapperForServerIssue(FSClientInputFile clientInputFile, ServerIssue serverIssue, Optional ruleDetails) { this.clientInputFile = clientInputFile; this.serverIssue = serverIssue; this.ruleDetails = ruleDetails; + + if (serverIssue instanceof FileLevelServerIssue) { + FileLevelServerIssue flsi = (FileLevelServerIssue)serverIssue; + startLine = null; + endLine = null; + } else if (serverIssue instanceof LineLevelServerIssue) { + LineLevelServerIssue llsi = (LineLevelServerIssue)serverIssue; + List lineHashes = clientInputFile.getLineHashes(); + // Naive implementation because of possible collision + // TODO improve search if possible (nearest line?) + int indexOf = lineHashes.indexOf(llsi.getLineHash()) + 1; + startLine = indexOf; + endLine = indexOf; + } else if (serverIssue instanceof RangeLevelServerIssue) { + RangeLevelServerIssue rlsi = (RangeLevelServerIssue)serverIssue; + TextRangeWithHash textRange = rlsi.getTextRange(); + startLine = textRange.getStartLine(); + endLine = textRange.getStartLine(); + } else { + startLine = null; + endLine = null; + } } @Override @@ -118,12 +145,7 @@ public TextRange getTextRange() { @Override public Integer getStartLine() { - if (serverIssue instanceof RangeLevelServerIssue) { - return ((RangeLevelServerIssue)serverIssue).getTextRange().getStartLine(); - } else if(serverIssue instanceof LineLevelServerIssue){ - return ((LineLevelServerIssue)serverIssue).getLine(); - } - return null; + return startLine; } @Override @@ -136,12 +158,7 @@ public Integer getStartLineOffset() { @Override public Integer getEndLine() { - if (serverIssue instanceof RangeLevelServerIssue) { - return ((RangeLevelServerIssue)serverIssue).getTextRange().getEndLine(); - } else if(serverIssue instanceof LineLevelServerIssue){ - return ((LineLevelServerIssue)serverIssue).getLine(); - } - return null; + return endLine; } @Override @@ -163,6 +180,4 @@ public Map getImpacts() { // TODO return Collections.emptyMap(); } - - } diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java index c7e77e7..836b317 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java @@ -57,23 +57,35 @@ disabledReason = "Disabled because require token to check remote issue on sample project" ) public class SonarLintRemoteEngineTest { - + private final Project sonarlint4netbeansSampleMavenProject = new ProjectMockedBuilder() - .projectDirectory(new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main")) + .projectDirectory(new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master")) .build(); - + private final File sonarlint4netbeansSampleMavenProjectNewClass = - new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java"); - + new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master/src/main/java/com/mycompany/mavenproject1/NewClass.java"); + + private final Project sonarlint4netbeansSampleMavenProjectWithLocalChange = new ProjectMockedBuilder() + .projectDirectory(new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master-with-local-change")) + .build(); + + private final File sonarlint4netbeansSampleMavenProjectNewClassWithLocalChange = + new File("./src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master-with-local-change/src/main/java/com/mycompany/mavenproject1/NewClass.java"); + @RegisterExtension SonarLintLookupMockedExtension sonarLintLookupMockedExtension = SonarLintLookupMockedExtension.builder() .logCall() .mockLookupMethodWith( SonarLintDataManager.class, new SonarLintDataManagerMockedBuilder() + // sonarlint4netbeans-sample-mavenproject / master branch .createPreferences(sonarlint4netbeansSampleMavenProject) .preferencesScope(sonarlint4netbeansSampleMavenProject, SonarLintProjectPreferenceScope.REMOTE) .addFileToProject(sonarlint4netbeansSampleMavenProject, sonarlint4netbeansSampleMavenProjectNewClass) + // sonarlint4netbeans-sample-mavenproject / master branch / local change + .createPreferences(sonarlint4netbeansSampleMavenProjectWithLocalChange) + .preferencesScope(sonarlint4netbeansSampleMavenProjectWithLocalChange, SonarLintProjectPreferenceScope.REMOTE) + .addFileToProject(sonarlint4netbeansSampleMavenProjectWithLocalChange, sonarlint4netbeansSampleMavenProjectNewClassWithLocalChange) .build() ).mockLookupMethodWith(Project.class, Mockito.mock(Project.class)) .mockLookupMethodWith(SonarLintRemoteConnectionConfigurationManagement.class, Mockito.mock(SonarLintRemoteConnectionConfigurationManagement.class)) @@ -114,6 +126,7 @@ public void remote() throws InterruptedException, IOException { sync.getTask().waitFinished(30_000); List issues = SonarLintUtils.analyze(FileUtil.toFileObject(sonarlint4netbeansSampleMavenProjectNewClass), null); Assertions.assertThat(issues) + .filteredOn("ruleKey", "java:S2629") .extracting(DefaultIssueTestImpl::toTuple) .containsAnyOf( new DefaultIssueTestImpl.Builder() @@ -125,4 +138,52 @@ public void remote() throws InterruptedException, IOException { .buildTuple() ); } + + @Test + public void remoteWithLocalChange() throws InterruptedException, IOException { + SonarLintRemoteConnectionConfigurationManagement sonarLintRemoteConnectionConfigurationManagement = Lookup.getDefault().lookup(SonarLintRemoteConnectionConfigurationManagement.class); + String connectionId = "testing-connection-id-sonarcloud"; + String projectKey = "philippefichet_sonarlint4netbeans-sample-mavenproject"; + String branchName = "master"; + String baseURL = "https://sonarcloud.io"; + boolean isSonarCloud = true; + String organization = "philippefichet"; + String login = System.getProperty("sonarlint4netbeans.test.remote.project-maven1.token"); + SonarLintRemoteConnectionConfiguration sonarLintRemoteConnectionConfiguration = new SonarLintRemoteConnectionConfiguration( + connectionId, + baseURL, + isSonarCloud + ); + Mockito.when(sonarLintRemoteConnectionConfigurationManagement.getAuthTokenFromConnectionId(connectionId)) + .thenReturn(Optional.of(login)); + Mockito.when(sonarLintRemoteConnectionConfigurationManagement.getSonarLintConnectionConfigurationFromConnectionId(connectionId)) + .thenReturn(Optional.of(sonarLintRemoteConnectionConfiguration)); + + SonarLintRemoteEngine remoteEngine = new SonarLintRemoteEngine(new Language[] {Language.JAVA}); + SonarLintRemoteProjectConfiguration sonarLintRemoteProjectConfiguration = new SonarLintRemoteProjectConfiguration( + sonarlint4netbeansSampleMavenProjectWithLocalChange, + connectionId, + projectKey, + organization, + branchName + ); + SonarLintRemoteProjectConfiguration.save(sonarlint4netbeansSampleMavenProjectWithLocalChange, connectionId, projectKey, organization); + TaskWrapper sync = remoteEngine.launchResyncTask( + sonarLintRemoteProjectConfiguration + ); + sync.getTask().waitFinished(30_000); + List issues = SonarLintUtils.analyze(FileUtil.toFileObject(sonarlint4netbeansSampleMavenProjectNewClassWithLocalChange), null); + Assertions.assertThat(issues) + .filteredOn("ruleKey", "java:S2629") + .extracting(DefaultIssueTestImpl::toTuple) + .containsAnyOf( + new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S2629") + .startLine(82) + .endLine(82) + .buildTuple() + ); + } } diff --git a/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master-with-local-change/src/main/java/com/mycompany/mavenproject1/NewClass.java b/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master-with-local-change/src/main/java/com/mycompany/mavenproject1/NewClass.java new file mode 100644 index 0000000..c3c9c04 --- /dev/null +++ b/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master-with-local-change/src/main/java/com/mycompany/mavenproject1/NewClass.java @@ -0,0 +1,84 @@ +/* + * sonarlint4netbeans-sample-mavenproject: Sample for SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.mycompany.mavenproject1; + +import java.nio.file.Path; + +public class NewClass { + private static String resource; + public static final String const_convition_violation = "TEST"; + + /** + * + * @deprecated + */ + @Deprecated + public void deprecatedMethod() {} + + public void MethodName_Convention_Violation() {} + + + // FIXME test + public static String getInstance() { + if (resource == null) { + synchronized (NewClass.class) { + if (resource == null) + resource = ""; + } + } + return resource; + } + + public static void lambdaTest() + { + String t = "toto"; + Runnable r = () -> { + for (int i = 0; i < 10; i++) { + System.out.println(t.trim()); + } + }; + new Thread(r).start(); + } + + public static void tooManyParameter(int param1, int param2, int param3, String param4, long param5, int param6, int param7, int param8, String param9) { + System.out.println("test"); + } + + /** + * Use "sonar.java.source=8" property to detected this issue + */ + public static void checkS3725WithExtraProperties() { + Path myPath = null; + if(java.nio.file.Files.exists(myPath)) { // Noncompliant + // do something + } + } + + // Add two lines to find a sonarcloud issue with local change + + /** + * Use "sonar.java.libraries=${projectDir}/target/lib/*.jar" and + * java:S2629 must be enabled and slf4j-api-1.7.36 copied in target/lib + * to show an issue + */ + public static void checkJavaS2629WithExtraPropertiesAndProjectDir(String arg1) { + org.slf4j.LoggerFactory.getLogger("Testing").debug("message: " + arg1); + } +} diff --git a/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java b/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master/src/main/java/com/mycompany/mavenproject1/NewClass.java similarity index 99% rename from src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java rename to src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master/src/main/java/com/mycompany/mavenproject1/NewClass.java index 28777b6..73474c9 100644 --- a/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-main/src/main/java/com/mycompany/mavenproject1/NewClass.java +++ b/src/test/samples/sonarlint4netbeans-sample-mavenproject/branch-master/src/main/java/com/mycompany/mavenproject1/NewClass.java @@ -75,7 +75,6 @@ public static void checkS3725WithExtraProperties() { * Use "sonar.java.libraries=${projectDir}/target/lib/*.jar" and * java:S2629 must be enabled and slf4j-api-1.7.36 copied in target/lib * to show an issue - * Or cloud analyse */ public static void checkJavaS2629WithExtraPropertiesAndProjectDir(String arg1) { org.slf4j.LoggerFactory.getLogger("Testing").debug("message: " + arg1); From c827fef7dd902f39c199631dce4a5368398a9c24 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Wed, 27 Dec 2023 15:09:30 +0100 Subject: [PATCH 13/17] Separate local and server issues --- pom.xml | 8 - .../SonarLintTaskScanner.java | 8 +- .../sonarlint4netbeans/SonarLintUtils.java | 13 +- .../annotation/SonarLintAnnotation.java | 62 ++++++-- .../SonarLintAnnotationHandler.java | 8 +- .../sonarlint4netbeans/git/GitUtils.java | 76 +++++++++ .../sonarlint4netbeans/issue/IssueUtils.java | 51 ++++++ .../IssueWrapperForServerIssue.java} | 6 +- .../remote/SonarLintRemoteEngine.java | 2 - .../SonarLintRemoteProjectConfiguration.java | 32 +--- .../sonarlint4netbeans/Bundle.properties | 18 +++ .../sonarlint4netbeans/layer.xml | 71 +++++++++ .../resources/sonarcloud-blocker.png | Bin 0 -> 666 bytes .../resources/sonarcloud-critical.png | Bin 0 -> 702 bytes .../resources/sonarcloud-info.png | Bin 0 -> 725 bytes .../resources/sonarcloud-major.png | Bin 0 -> 712 bytes .../resources/sonarcloud-minor.png | Bin 0 -> 679 bytes .../resources/sonarcloud.png | Bin 0 -> 636 bytes .../sonarcloud-annotation.xml | 14 ++ .../sonarcloud-blocker-annotation.xml | 14 ++ .../sonarcloud-critical-annotation.xml | 14 ++ .../sonarcloud-info-annotation.xml | 14 ++ .../sonarcloud-major-annotation.xml | 14 ++ .../sonarcloud-minor-annotation.xml | 14 ++ .../SonarLintAnalyserIssueComparatorTest.java | 1 + .../SonarLintEngineImplJavaPluginTest.java | 1 + ...narLintEngineImplJavascriptPluginTest.java | 1 + .../SonarLintEngineImplPhpPluginTest.java | 1 + .../SonarLintEngineImplTestUtils.java | 1 + .../SonarLintEngineImplWebPluginTest.java | 1 + .../SonarLintEngineImplXmlPluginTest.java | 1 + .../SonarLintUtilsTest.java | 1 + .../{ => issue}/DefaultIssueTestImpl.java | 2 +- .../issue/IssueTestFactory.java | 150 ++++++++++++++++++ .../remote/SonarLintRemoteEngineTest.java | 40 +++-- 35 files changed, 554 insertions(+), 85 deletions(-) create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/git/GitUtils.java create mode 100644 src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueUtils.java rename src/main/java/com/github/philippefichet/sonarlint4netbeans/{remote/wrapper/SonarLintIssueWrapperForServerIssue.java => issue/IssueWrapperForServerIssue.java} (95%) create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-blocker.png create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-critical.png create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-info.png create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-major.png create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-minor.png create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud.png create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-annotation.xml create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-blocker-annotation.xml create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-critical-annotation.xml create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-info-annotation.xml create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-major-annotation.xml create mode 100644 src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-minor-annotation.xml rename src/test/java/com/github/philippefichet/sonarlint4netbeans/{ => issue}/DefaultIssueTestImpl.java (99%) create mode 100644 src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueTestFactory.java diff --git a/pom.xml b/pom.xml index 29b64ff..d1322a9 100644 --- a/pom.xml +++ b/pom.xml @@ -433,12 +433,6 @@ org-netbeans-modules-keyring ${org.netbeans.version} - - - org.netbeans.api - org-netbeans-libs-git - ${org.netbeans.version} - org.junit.jupiter junit-jupiter-api @@ -496,8 +490,6 @@ https://sonarcloud.io plain - - warn ${env.SONARLINT4NETBEANS_TEST_REMOTE_PROJECT_MAVEN1_TOKEN} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java index 780874d..6f9da8e 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintTaskScanner.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.IssueWrapperForServerIssue; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; @@ -69,10 +70,15 @@ public List scan(FileObject fileObject) { return analyze.stream() .map(issue -> { Integer startLine = issue.getStartLine(); + // TODO use rules store Optional ruleDetails = sonarLintEngine.getRuleDetails(issue.getRuleKey()); + String prefix = issue instanceof IssueWrapperForServerIssue + ? "nb-sonarcloud-" + : "nb-sonarlint-"; + String groupName = issue.getSeverity().name().toLowerCase(); return Task.create( fileObject, - "nb-sonarlint-" + issue.getSeverity().name().toLowerCase(), + prefix + groupName, issue.getRuleKey() + " = " + ruleDetails.map(StandaloneRuleDetails::getName).orElse("unknown"), startLine == null ? 1 : startLine ); diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java index e24ee89..10fbd4a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtils.java @@ -19,10 +19,11 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.IssueUtils; +import com.github.philippefichet.sonarlint4netbeans.issue.IssueWrapperForServerIssue; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; import com.github.philippefichet.sonarlint4netbeans.remote.SonarLintRemoteEngine; import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteProjectConfiguration; -import com.github.philippefichet.sonarlint4netbeans.remote.wrapper.SonarLintIssueWrapperForServerIssue; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -350,18 +351,20 @@ public void setIndeterminate(boolean indeterminate) { } } ); - List serverIssues = remoteEngine.getServerIssues(sonarLintRemoteProjectConfiguration, clientInputFile.relativePath()); serverIssues.stream() - .map( - s -> - new SonarLintIssueWrapperForServerIssue( + .map((ServerIssue s) -> + new IssueWrapperForServerIssue( clientInputFile, s, // TODO replace by a sonarcloud/sonarqube rules store sonarLintEngine.getRuleDetails(s.getRuleKey()) ) ) + // Remove server issue not found in local change + .filter((IssueWrapperForServerIssue s) -> s.getStartLine() != -1) + // Add only no local issue + .filter((IssueWrapperForServerIssue s) -> !IssueUtils.containsSimilarIssue(listener, s)) .forEach(listener::add); LOG.fine(() -> "Analyze (Remote) result for file \"" + clientInputFile.uri() + "\" : " + remoteAnalyze); return listener; diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java index 17a1e59..b9650d2 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotation.java @@ -36,15 +36,32 @@ public class SonarLintAnnotation extends Annotation { public static final String ANNOTATION_TYPE_MAJOR = "com-github-philippefichet-sonarlint4netbeans-annotation-major"; public static final String ANNOTATION_TYPE_CRITIAL = "com-github-philippefichet-sonarlint4netbeans-annotation-critical"; public static final String ANNOTATION_TYPE_BLOCKER = "com-github-philippefichet-sonarlint4netbeans-annotation-blocker"; + + public static final String ANNOTATION_TYPE_SONARCLOUD_GENERIC = "com-github-philippefichet-sonarlint4netbeans-annotation-sonarcloud-generic"; + public static final String ANNOTATION_TYPE_SONARCLOUD_INFO = "com-github-philippefichet-sonarlint4netbeans-annotation-sonarcloud-info"; + public static final String ANNOTATION_TYPE_SONARCLOUD_MINOR = "com-github-philippefichet-sonarlint4netbeans-annotation-sonarcloud-minor"; + public static final String ANNOTATION_TYPE_SONARCLOUD_MAJOR = "com-github-philippefichet-sonarlint4netbeans-annotation-sonarcloud-major"; + public static final String ANNOTATION_TYPE_SONARCLOUD_CRITIAL = "com-github-philippefichet-sonarlint4netbeans-annotation-sonarcloud-critical"; + public static final String ANNOTATION_TYPE_SONARCLOUD_BLOCKER = "com-github-philippefichet-sonarlint4netbeans-annotation-sonarcloud-blocker"; + private final long startOffest; private final int length; private final String shortDescription; private final String ruleKey; private final String ruleName; private final IssueSeverity severity; + private final Origin origin; + + public enum Origin + { + SONARLINT, + SONARCLOUD, + SONARQUBE + } - public SonarLintAnnotation(String ruleKey, String ruleName, Map ruleParams, IssueSeverity severity, long startOffest, int length) { + public SonarLintAnnotation(Origin origin, String ruleKey, String ruleName, Map ruleParams, IssueSeverity severity, long startOffest, int length) { super(); + this.origin = origin; this.startOffest = startOffest; this.length = length; this.ruleKey = ruleKey; @@ -86,19 +103,36 @@ public int getLength() { @Override public String getAnnotationType() { - switch(severity.name()) { - case "INFO": - return ANNOTATION_TYPE_INFO; - case "MINOR": - return ANNOTATION_TYPE_MINOR; - case "MAJOR": - return ANNOTATION_TYPE_MAJOR; - case "CRITICAL": - return ANNOTATION_TYPE_CRITIAL; - case "BLOCKER": - return ANNOTATION_TYPE_BLOCKER; - default: - return ANNOTATION_TYPE_GENERIC; + if (origin == Origin.SONARCLOUD) { + switch(severity.name()) { + case "INFO": + return ANNOTATION_TYPE_SONARCLOUD_INFO; + case "MINOR": + return ANNOTATION_TYPE_SONARCLOUD_MINOR; + case "MAJOR": + return ANNOTATION_TYPE_SONARCLOUD_MAJOR; + case "CRITICAL": + return ANNOTATION_TYPE_SONARCLOUD_CRITIAL; + case "BLOCKER": + return ANNOTATION_TYPE_SONARCLOUD_BLOCKER; + default: + return ANNOTATION_TYPE_SONARCLOUD_GENERIC; + } + } else { + switch(severity.name()) { + case "INFO": + return ANNOTATION_TYPE_INFO; + case "MINOR": + return ANNOTATION_TYPE_MINOR; + case "MAJOR": + return ANNOTATION_TYPE_MAJOR; + case "CRITICAL": + return ANNOTATION_TYPE_CRITIAL; + case "BLOCKER": + return ANNOTATION_TYPE_BLOCKER; + default: + return ANNOTATION_TYPE_GENERIC; + } } } diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java index 5d17d3b..43a717a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/annotation/SonarLintAnnotationHandler.java @@ -23,6 +23,7 @@ import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManagerUtils; import com.github.philippefichet.sonarlint4netbeans.SonarLintEngine; import com.github.philippefichet.sonarlint4netbeans.SonarLintUtils; +import com.github.philippefichet.sonarlint4netbeans.issue.IssueWrapperForServerIssue; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.IOException; @@ -108,7 +109,7 @@ public void propertyChange(PropertyChangeEvent evt) { } List issues = SonarLintUtils.analyze(fileObject, textToAnalyze); - issues.forEach(sue -> { + issues.forEach((Issue sue) -> { Integer startLine = sue.getStartLine(); Integer endLine = sue.getEndLine(); Integer startLineOffset = sue.getStartLineOffset(); @@ -130,10 +131,15 @@ public void propertyChange(PropertyChangeEvent evt) { int nbEndLineOffset = NbDocument.findLineOffset(editorCookie.getDocument(), endLine - 1); int endOffset = nbEndLineOffset + endLineOffset; int length = endOffset - startOffset; + SonarLintAnnotation.Origin origin = + sue instanceof IssueWrapperForServerIssue + ? SonarLintAnnotation.Origin.SONARCLOUD + : SonarLintAnnotation.Origin.SONARLINT; standaloneSonarLintEngine.getRuleDetails(sue.getRuleKey()).ifPresent( (StandaloneRuleDetails ruleDetails) -> currentAnnocationOnFileObject.add( new SonarLintAnnotation( + origin, sue.getRuleKey(), ruleDetails.getName(), SonarLintUtils.extractRuleParameters(standaloneSonarLintEngine, sue.getRuleKey(), projectForAnalyse), diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/git/GitUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/git/GitUtils.java new file mode 100644 index 0000000..663edaf --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/git/GitUtils.java @@ -0,0 +1,76 @@ +/* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.git; + +import java.io.IOException; +import java.util.Optional; +import org.openide.filesystems.FileObject; +import org.openide.util.Exceptions; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public final class GitUtils { + + private GitUtils() { + } + + /** + * Search git active branch for this file + * @param file file to search git active branch + * @return branch name if found + */ + public static Optional getProjectActiveBranch(FileObject file) { + if (file == null) { + return Optional.empty(); + } + Optional dotGitFolder = searchDotGitFolder(file); + if (dotGitFolder.isPresent()) { + try { + return Optional.of( + dotGitFolder.get() + .getFileObject("HEAD") + .asText() + .split("\n")[0] + .substring("ref: refs/heads/".length()) + ); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + } + return Optional.empty(); + } + + /** + * Search .git folder from directory + * @param file directory to search + * @return ".git" FileObject if found + */ + public static Optional searchDotGitFolder(FileObject file) + { + FileObject fileObject = file; + while (fileObject.getFileObject(".git") == null && fileObject.getParent() != null) { + fileObject = fileObject.getParent(); + } + return Optional.ofNullable(fileObject.getFileObject(".git")); + } + +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueUtils.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueUtils.java new file mode 100644 index 0000000..6f3a53c --- /dev/null +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueUtils.java @@ -0,0 +1,51 @@ +/* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.issue; + +import java.util.List; +import java.util.Objects; +import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public final class IssueUtils { + + private IssueUtils() { + } + + public static boolean containsSimilarIssue(List issues, Issue issue) + { + for (Issue sue : issues) { + if(Objects.equals(sue.getRuleKey(), issue.getRuleKey()) + && Objects.equals(sue.getStartLine(), issue.getStartLine()) + && Objects.equals(sue.getEndLine(), issue.getEndLine()) + // if the issue is less accurate + && (issue.getStartLineOffset() == null || Objects.equals(sue.getStartLineOffset(), issue.getStartLineOffset())) + // if the issue is less accurate + && (issue.getEndLineOffset() == null || Objects.equals(sue.getEndLineOffset(), issue.getEndLineOffset())) + ) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueWrapperForServerIssue.java similarity index 95% rename from src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java rename to src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueWrapperForServerIssue.java index 06fba2b..43eedd5 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/wrapper/SonarLintIssueWrapperForServerIssue.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueWrapperForServerIssue.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.github.philippefichet.sonarlint4netbeans.remote.wrapper; +package com.github.philippefichet.sonarlint4netbeans.issue; import com.github.philippefichet.sonarlint4netbeans.FSClientInputFile; import java.util.Collections; @@ -46,7 +46,7 @@ * * @author FICHET Philippe <philippe.fichet@laposte.net> */ -public class SonarLintIssueWrapperForServerIssue implements Issue { +public class IssueWrapperForServerIssue implements Issue { private final ServerIssue serverIssue; private final FSClientInputFile clientInputFile; @@ -54,7 +54,7 @@ public class SonarLintIssueWrapperForServerIssue implements Issue { private final Integer startLine; private final Integer endLine; - public SonarLintIssueWrapperForServerIssue(FSClientInputFile clientInputFile, ServerIssue serverIssue, Optional ruleDetails) { + public IssueWrapperForServerIssue(FSClientInputFile clientInputFile, ServerIssue serverIssue, Optional ruleDetails) { this.clientInputFile = clientInputFile; this.serverIssue = serverIssue; this.ruleDetails = ruleDetails; diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java index 3b2d42c..713bd9a 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngine.java @@ -217,8 +217,6 @@ public List getServerIssues( ); ConnectedSonarLintEngineImpl connectedSonarLintEngineImpl = getConnectedSonarLintEngineImpl(sonarLintRemoteProjectConfiguration); -// connectedSonarLintEngineImpl.getActiveRuleDetails(endpoint, client, relativizePathToAnalyze, relativizePathToAnalyze); -// connectedSonarLintEngineImpl.downloadAllServerIssuesForFile(endpoint, client, projectBinding, relativizePathToAnalyze, relativizePathToAnalyze, monitor);AllServerIssues(endpoint, client, relativizePathToAnalyze, relativizePathToAnalyze, monitor); return connectedSonarLintEngineImpl.getServerIssues( projectBinding, findBestBranch(connectedSonarLintEngineImpl, sonarLintRemoteProjectConfiguration), diff --git a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java index 7bba2d6..e33a318 100644 --- a/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java +++ b/src/main/java/com/github/philippefichet/sonarlint4netbeans/remote/configuration/SonarLintRemoteProjectConfiguration.java @@ -20,16 +20,10 @@ package com.github.philippefichet.sonarlint4netbeans.remote.configuration; import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManager; -import java.io.File; -import java.util.Map; +import com.github.philippefichet.sonarlint4netbeans.git.GitUtils; import java.util.Optional; import java.util.prefs.Preferences; import org.netbeans.api.project.Project; -import org.netbeans.libs.git.GitBranch; -import org.netbeans.libs.git.GitException; -import org.netbeans.libs.git.GitRepository; -import org.netbeans.libs.git.progress.ProgressMonitor; -import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; /** @@ -67,20 +61,12 @@ public static SonarLintRemoteProjectConfiguration fromProject(Project project) { } public static SonarLintRemoteProjectConfiguration fromProject(Project project, String connectionId, String projectKey, String organization) { - File projectDir = FileUtil.toFile(project.getProjectDirectory()); - // TODO - GitRepository instance = GitRepository.getInstance(projectDir); - Map branches = null; - try { - branches = instance.createClient().getBranches(false, new ProgressMonitor.DefaultProgressMonitor()); - } catch (GitException ex) { - } return new SonarLintRemoteProjectConfiguration( project, connectionId, projectKey, organization, - branches == null ? null : branches.values().iterator().next().getName() + GitUtils.getProjectActiveBranch(project.getProjectDirectory()).orElse(null) ); } @@ -96,19 +82,7 @@ public Optional getProjectActiveBranch() { if (activeBranch != null) { return Optional.of(activeBranch); } - File projectDir = FileUtil.toFile(project.getProjectDirectory()); - - GitRepository instance = GitRepository.getInstance(projectDir); - Map branches = null; - try { - branches = instance.createClient().getBranches(false, new ProgressMonitor.DefaultProgressMonitor()); - } catch (GitException ex) { - // Exceptions.printStackTrace(ex); - } - if (branches != null) { - return Optional.of(branches.values().iterator().next().getName()); - } - return Optional.empty(); + return GitUtils.getProjectActiveBranch(project.getProjectDirectory()); } public String getConnectionId() { diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/Bundle.properties b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/Bundle.properties index 02d6d36..91fdf80 100644 --- a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/Bundle.properties +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/Bundle.properties @@ -27,6 +27,7 @@ SonarLintPanel.categoriesLabel.text=Categories LBL_sonarlint_group=SonarLint HINT_sonarlint_group=SonarLint ICON_sonarlint=com/github/philippefichet/sonarlint4netbeans/resources/sonarlint.png +# SonarLint "Task" LBL_sonarlint_group_info=SonarLint Info HINT_sonarlint_group_info=SonarLint Info ICON_sonarlint_info=com/github/philippefichet/sonarlint4netbeans/resources/sonarlint-info.png @@ -42,6 +43,23 @@ ICON_sonarlint_critical=com/github/philippefichet/sonarlint4netbeans/resources/s LBL_sonarlint_group_blocker=SonarLint Blocker HINT_sonarlint_group_blocker=SonarLint Blocker ICON_sonarlint_blocker=com/github/philippefichet/sonarlint4netbeans/resources/sonarlint-blocker.png +# SonarCloud "Task" +LBL_sonarcloud_group_info=SonarCloud Info +HINT_sonarcloud_group_info=SonarCloud Info +ICON_sonarcloud_info=com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-info.png +LBL_sonarcloud_group_minor=SonarCloud Minor +HINT_sonarcloud_group_minor=SonarCloud Minor +ICON_sonarcloud_minor=com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-minor.png +LBL_sonarcloud_group_major=SonarCloud Major +HINT_sonarcloud_group_major=SonarCloud Major +ICON_sonarcloud_major=com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-major.png +LBL_sonarcloud_group_critical=SonarCloud Critical +HINT_sonarcloud_group_critical=SonarCloud Critical +ICON_sonarcloud_critical=com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-critical.png +LBL_sonarcloud_group_blocker=SonarCloud Blocker +HINT_sonarcloud_group_blocker=SonarCloud Blocker +ICON_sonarcloud_blocker=com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-blocker.png + SonarRuleDetailsTopComponent.sonarRuleKeyFilter.toolTipText=SonarLint Rule key SonarRuleDetailsTopComponent.sonarRuleKeyFilter.text= OptionsExport.displayName=SonarLint diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/layer.xml b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/layer.xml index d1c590d..93c02a6 100644 --- a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/layer.xml +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/layer.xml @@ -83,6 +83,30 @@ url="nbresloc:/com/github/philippefichet/sonarlint4netbeans/sonarlint-blocker-annotation.xml"> + + + + + + + + + + + + + + + + + + @@ -96,6 +120,7 @@ + @@ -141,6 +166,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-blocker.png b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-blocker.png new file mode 100644 index 0000000000000000000000000000000000000000..e28c3ff32da9be56fcebf1f752fe55b5de40d1ee GIT binary patch literal 666 zcmV;L0%iS)P)QsLd>p zV$a)6FBkXqd;Z$$G5~x%TWK7d4(IcwXiq?&^XkpL0}UIpmuxB6ws;b1V{7ehxOtH> z&JkZ2%nt#iBul2uv?f!S6NxtpQ7JQs@$z6!1At)Bze!R(;+#y=OJNrhq|tCA04Rkb zl)AfrYp$X+e#NUd_q4F)mx=Ir=STi;uWcEJqnYYMX+Uf^0){KlUiWbPRCwNS(pLb^ zF$sFM|I?0pZOa~X%MunH!VIMqrhDlAwvdDx{(N^e0?mhuewBjS8MXPo04Zo_T+-C0 zre|BC&m(Tj`CKu{cYpo&C`<=%OYvIfI8K($1?FI zi`i_al{1uJ;C6gOaNDs*N@!zrISCL)LA`OYVe17ChWd=XE8mPw6mBt z%~G-9G-G!TEBaT@QI;g`y#)X!APUXz;byBE(Pp-ac>vhCmCnKs@&lX9-}w1(@zJ$6 zn+IM?efs-LTnB^Mwhc=LFxUDK?M+%p=K(;FSdkR5IRMCF%y&`vbUS^65SZvlIH@U( z$heo00U+Q601yx>eNiax#rkW%BcWA|Xaune^m^Tvl8B6Zy;qPlfAr1}aK_JVo+&lq z9Sa2eOhCN4Xf(S_9!_NUSemXqncJ)0U)Vk;j&ejVbdwA$FZ&2tQi!J}XX`iX2T@h< zUNn-^j-qJ3qQ-eDJm&vxRJC!z88qE>6H}dlAf82YpUZIbe|Zr7j<1kuq5uE@07*qoM6N<$f(%?PO#lD@ literal 0 HcmV?d00001 diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-info.png b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-info.png new file mode 100644 index 0000000000000000000000000000000000000000..4d78ec1365a6b5eb8bee8a9c57e7c1083a774327 GIT binary patch literal 725 zcmV;`0xJE9P)zxVgM+q`RkuHt59>TUPgmxo&eMVK`F?)q9L`VR zoTEOn5$~`7q5!;?f#xaLYz0+Cj($nh*9!H3Y{VPmpyy^B1NmiJu*Ff{#Go2ydrLnm z23|RBiGG~_Cmt{-fjb?9d6&q4V*HCPAv{uVeE7gd( z#|ljE7$F<+g#bKcf@oMXcL^p|Y#`w5p8M`%R8Fl6u_Vu6>^c5F{Kt z_S|{qPpugMQl|YyJvXxgu5C=W=Ym_)#${GV{nJQF1f%UiUa^0<;`7y9JN&b z*Hx#MK#3ZXbfl;GKp?w(@NHwCaf=wX3re(sS>yLlEG#aa`fNEAs5QH^1j4CDu(HB= z;kV+Kf$ED*lk>>a)=N@>S^xmyTnxi(qu31@L(f`C>pv~;d+^Qwe00000NkvXX Hu0mjfycbEl literal 0 HcmV?d00001 diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-major.png b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud-major.png new file mode 100644 index 0000000000000000000000000000000000000000..f78a395aa481d63c37e2f7a3d9d51b0d657aaf7f GIT binary patch literal 712 zcmV;(0yq7MP)yv}@TpXmM?O(?Z8JO=(3)jqUCmaUDU>)#3V^#(x3rTDC%3 zJlJwP&~Q)bqD}fdc~%t7o`=Q19)b2x;zH}r=C7v6cH7oj>OJS!(fPt0012l z2pD&YW&3@xJZ?yCBs07D^n`aXs=p9zzy^T8Q(%Tt03fXhQAef>$-komN#IK)j`=aF86^?F_CumI#qZ?~e+IJ1T-%RaP*b zDK>M>Ps2w!6d+=6^z?R%B?luD-btaf-*HV704&@0lVcqw@U29B)j2$6ua>PcMCGtx u==BI@73kO!belt&XNHmny8zwp{=^@N{|*C`=zMtq0000$&3>*No&?jZzJoz>|i)ozLYpwc75D zEkE9il7xGXrJGEcIxUVD;D-HrGQ+eHFHQve&*e3hhxr154Ff>mQUtxr?TZ}12@C*? zFy5%-Jh;x#=@1nmHQmMt<8w>hGv~nopl-G75`3EzX!`D)b`YvIzbHxcZ2MKeef?L* zmmu7}6T-!HCC0(0*q)hCC03oSM7{Xh0}*rOdTH^G9Yy(2Ds#fMLeJ6G=Ix_yS0=>% zhATZk+I;R~GLl)DI{C_urJDq9oKD`iJ;)|-q)K3E27cpAlj+7z90T_L^+19O{tf^D N002ovPDHLkV1iZ(Fz5gP literal 0 HcmV?d00001 diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud.png b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/resources/sonarcloud.png new file mode 100644 index 0000000000000000000000000000000000000000..096f4a4570365fabf06b54787117aa008f264942 GIT binary patch literal 636 zcmV-?0)zdDP)G4yObpr;K_3V~WDyh*l#3E(Y)o321VJ0M z76w|2TGqNC68a>`sfVp!E7>0{&J>0Q9jq!3a}~&>YTYpamsxFNJ8OF!QL8R zH3}D_TkC7-Rp^F+t&L-Ez5?ef05P{nprivlK~HpmiFZI|X|R1wHCq;{3-BCh%A8&J zmTTKoq2N>D71)B4t}$vA|56%AwFriAx?#GA^GoSFz)ppB#bV4_sP%$=pcTx4JQLGG z9|S#SmIpmgB)vl`uRLnbFQrc-PGPhle8fE$1eeU}To4OJK>L6uzyq63Bn#IWQTPXY W>f@vWy4djm0000 + + + diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-blocker-annotation.xml b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-blocker-annotation.xml new file mode 100644 index 0000000..bedf725 --- /dev/null +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-blocker-annotation.xml @@ -0,0 +1,14 @@ + + + + diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-critical-annotation.xml b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-critical-annotation.xml new file mode 100644 index 0000000..a636cf7 --- /dev/null +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-critical-annotation.xml @@ -0,0 +1,14 @@ + + + + diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-info-annotation.xml b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-info-annotation.xml new file mode 100644 index 0000000..1ea8078 --- /dev/null +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-info-annotation.xml @@ -0,0 +1,14 @@ + + + + diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-major-annotation.xml b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-major-annotation.xml new file mode 100644 index 0000000..315f1fc --- /dev/null +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-major-annotation.xml @@ -0,0 +1,14 @@ + + + + diff --git a/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-minor-annotation.xml b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-minor-annotation.xml new file mode 100644 index 0000000..caaa8a2 --- /dev/null +++ b/src/main/resources/com/github/philippefichet/sonarlint4netbeans/sonarcloud-minor-annotation.xml @@ -0,0 +1,14 @@ + + + + diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java index 174e018..40d4994 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintAnalyserIssueComparatorTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.treenode.SonarLintAnalyserIssueComparator; import java.io.File; import java.util.ArrayList; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java index bbd5594..daab693 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavaPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java index 9bf776a..e4a41d4 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplJavascriptPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java index f1e1438..8a77e59 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplPhpPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java index 8b42293..f5cef43 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplTestUtils.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import java.io.File; import java.io.IOException; import java.util.ArrayList; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java index 407e52c..7f1afb1 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplWebPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java index 4714539..9b6da4f 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintEngineImplXmlPluginTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import java.io.File; import java.io.IOException; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java index cb0fed5..62efe05 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/SonarLintUtilsTest.java @@ -19,6 +19,7 @@ */ package com.github.philippefichet.sonarlint4netbeans; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintEngineEnableLanguage; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/DefaultIssueTestImpl.java similarity index 99% rename from src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java rename to src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/DefaultIssueTestImpl.java index b5252d8..07daaf6 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/DefaultIssueTestImpl.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/DefaultIssueTestImpl.java @@ -17,7 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ -package com.github.philippefichet.sonarlint4netbeans; +package com.github.philippefichet.sonarlint4netbeans.issue; import java.util.List; import java.util.Map; diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueTestFactory.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueTestFactory.java new file mode 100644 index 0000000..4b8b38a --- /dev/null +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/issue/IssueTestFactory.java @@ -0,0 +1,150 @@ +/* + * sonarlint4netbeans: SonarLint integration for Apache Netbeans + * Copyright (C) 2023 Philippe FICHET. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package com.github.philippefichet.sonarlint4netbeans.issue; + +import org.sonarsource.sonarlint.core.commons.IssueSeverity; +import org.sonarsource.sonarlint.core.commons.RuleType; + +/** + * + * @author FICHET Philippe <philippe.fichet@laposte.net> + */ +public final class IssueTestFactory { + + private IssueTestFactory() { + } + + public static DefaultIssueTestImpl.Builder javaS100(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MINOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S100") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS106(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S106") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS107(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S107") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS115(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.CRITICAL) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S115") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS1133(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.INFO) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S1133") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS1134(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S1134") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS1172(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S1172") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS1186(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.CRITICAL) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S1186") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS2168(Integer line, Integer startLineOffset, Integer endLineOffset) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.BLOCKER) + .type(RuleType.BUG) + .ruleKey("java:S2168") + .startLine(line) + .startLineOffset(startLineOffset) + .endLine(line) + .endLineOffset(endLineOffset); + } + + public static DefaultIssueTestImpl.Builder javaS2629(Integer line) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S2629") + .startLine(line) + .endLine(line); + } + public static DefaultIssueTestImpl.Builder javaS3457(Integer line) { + return new DefaultIssueTestImpl.Builder() + .severity(IssueSeverity.MAJOR) + .type(RuleType.CODE_SMELL) + .ruleKey("java:S3457") + .startLine(line) + .endLine(line); + } + +} diff --git a/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java b/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java index 836b317..7fb60d7 100644 --- a/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java +++ b/src/test/java/com/github/philippefichet/sonarlint4netbeans/remote/SonarLintRemoteEngineTest.java @@ -19,11 +19,12 @@ */ package com.github.philippefichet.sonarlint4netbeans.remote; -import com.github.philippefichet.sonarlint4netbeans.DefaultIssueTestImpl; import com.github.philippefichet.sonarlint4netbeans.ProjectMockedBuilder; import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManager; import com.github.philippefichet.sonarlint4netbeans.SonarLintDataManagerMockedBuilder; import com.github.philippefichet.sonarlint4netbeans.SonarLintUtils; +import com.github.philippefichet.sonarlint4netbeans.issue.DefaultIssueTestImpl; +import com.github.philippefichet.sonarlint4netbeans.issue.IssueTestFactory; import com.github.philippefichet.sonarlint4netbeans.junit.jupiter.extension.SonarLintLookupMockedExtension; import com.github.philippefichet.sonarlint4netbeans.project.SonarLintProjectPreferenceScope; import com.github.philippefichet.sonarlint4netbeans.remote.configuration.SonarLintRemoteConnectionConfiguration; @@ -43,9 +44,7 @@ import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; import org.sonarsource.sonarlint.core.client.api.common.analysis.Issue; -import org.sonarsource.sonarlint.core.commons.IssueSeverity; import org.sonarsource.sonarlint.core.commons.Language; -import org.sonarsource.sonarlint.core.commons.RuleType; /** * @@ -126,16 +125,23 @@ public void remote() throws InterruptedException, IOException { sync.getTask().waitFinished(30_000); List issues = SonarLintUtils.analyze(FileUtil.toFileObject(sonarlint4netbeansSampleMavenProjectNewClass), null); Assertions.assertThat(issues) - .filteredOn("ruleKey", "java:S2629") .extracting(DefaultIssueTestImpl::toTuple) - .containsAnyOf( - new DefaultIssueTestImpl.Builder() - .severity(IssueSeverity.MAJOR) - .type(RuleType.CODE_SMELL) - .ruleKey("java:S2629") - .startLine(80) - .endLine(80) - .buildTuple() + .containsExactlyInAnyOrder( + // Local issue + IssueTestFactory.javaS115(26, 31, 56).buildTuple(), + IssueTestFactory.javaS1133(33, 16, 32).buildTuple(), + IssueTestFactory.javaS1186(33, 16, 32).buildTuple(), + IssueTestFactory.javaS100(35, 16, 47).buildTuple(), + IssueTestFactory.javaS1186(35, 16, 47).buildTuple(), + IssueTestFactory.javaS1134(38, 0, 17).buildTuple(), + IssueTestFactory.javaS2168(41, 12, 24).buildTuple(), + IssueTestFactory.javaS106(54, 16, 26).buildTuple(), + IssueTestFactory.javaS1172(60, 44, 50).buildTuple(), + IssueTestFactory.javaS107(60, 23, 39).buildTuple(), + IssueTestFactory.javaS106(61, 8, 18).buildTuple(), + // Server issue + IssueTestFactory.javaS2629(80).buildTuple(), + IssueTestFactory.javaS3457(80).buildTuple() ); } @@ -176,14 +182,6 @@ public void remoteWithLocalChange() throws InterruptedException, IOException { Assertions.assertThat(issues) .filteredOn("ruleKey", "java:S2629") .extracting(DefaultIssueTestImpl::toTuple) - .containsAnyOf( - new DefaultIssueTestImpl.Builder() - .severity(IssueSeverity.MAJOR) - .type(RuleType.CODE_SMELL) - .ruleKey("java:S2629") - .startLine(82) - .endLine(82) - .buildTuple() - ); + .containsAnyOf(IssueTestFactory.javaS2629(82).buildTuple()); } } From 0817ef3a76c7ffab4ee11e5206d20758065afc63 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 28 Dec 2023 11:55:16 +0100 Subject: [PATCH 14/17] "sonarcloud" branch analysis --- .github/workflows/maven.yml | 7 +++++-- README.adoc | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 0ad5293..f62d61f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -5,9 +5,12 @@ name: Java CI with Maven on: push: - branches: [ master ] + branches: + - master + - sonarcloud pull_request: - branches: [ master ] + branches: + - master jobs: build: diff --git a/README.adoc b/README.adoc index ae8273e..b9f02c1 100644 --- a/README.adoc +++ b/README.adoc @@ -27,9 +27,14 @@ It requests netbeans in version 13.0 or higher and Java in version 11 or higher. - Enable or disabled test rules on test files - Severity icons - Partial Support on C/C++ project (show xref:README-CFamily.adoc[README-CFamily]) +- SonarCloud/SonarQube support == Release 2.x to 3.x +== SonarCloud + +Branch analysis must be https://docs.sonarsource.com/sonarcloud/enriching/branch-analysis-setup/#sonarlint[correctly configured] to be fully functional, otherwise only analysis on the main branch will be performed. + === Plugins SonarLint no longer uses URLs to find plugins but file paths. + From cbbeed882a8e352f38ddaf9f58d429f7c769ccbd Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 28 Dec 2023 12:13:53 +0100 Subject: [PATCH 15/17] "sonarcloud" branch analysis --- .github/workflows/maven.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index f62d61f..650a2ba 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -9,8 +9,7 @@ on: - master - sonarcloud pull_request: - branches: - - master + types: [opened, synchronize, reopened] jobs: build: From 51cf953edacce4bbea6e8b66e2e3fb402860e472 Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 28 Dec 2023 13:33:20 +0100 Subject: [PATCH 16/17] branch-* analysis --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 650a2ba..45e6e2e 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -7,7 +7,7 @@ on: push: branches: - master - - sonarcloud + - branch-* pull_request: types: [opened, synchronize, reopened] From ae7f2b7653cd8c336c228f51acf900dde3a4a27d Mon Sep 17 00:00:00 2001 From: FICHET Philippe Date: Thu, 28 Dec 2023 14:10:48 +0100 Subject: [PATCH 17/17] branch-* analysis --- .github/workflows/sonarcloud.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index a9aef74..1afb545 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -3,6 +3,7 @@ on: push: branches: - master + - branch-* pull_request: types: [opened, synchronize, reopened] jobs: