Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove includes not used directly #2062

Merged
merged 3 commits into from Apr 12, 2024
Merged

Remove includes not used directly #2062

merged 3 commits into from Apr 12, 2024

Conversation

dforsi
Copy link
Contributor

@dforsi dforsi commented Apr 8, 2024

This PR:

  • removes unused includes from *.cpp and from just one *.h
  • replaces some includes with others more specific

I didn't check *.h files except adsbdemodsink.h. At a later time we might try to use IWYU (https://github.com/include-what-you-use/include-what-you-use) but in my experience it needs a lot of effort.
I trust that the CI will catch any error I may have introduced in the configurations that I can't currently compile.

The list of added/replaced includes:

$ git diff b939a98f6bfa100224df10bec423222dbcd0c8ec | grep ^+ | grep -v +++ | sort | uniq -c
      2 +
     14 +#include "audio/audiodevicemanager.h"
      1 +#include "bladerf2mimo.h"
      5 +#include "maincore.h"
      1 +#include "mapsettingsdialog.h"
      2 +#include "util/message.h"

The list of deleted includes is too long, here are some the largest deletions:

$ git diff b939a98f6bfa100224df10bec423222dbcd0c8ec | grep ^- | grep -v ^--- | sort | uniq -c | sort -nr | head
    263 -#include "dsp/dspengine.h"
    110 -#include "util/simpleserializer.h"
     58 -#include "feature/feature.h"
     55 -#include "gui/devicestreamselectiondialog.h"
     39 -#include "mainwindow.h"
     38 -#include "util/db.h"
     36 -
     26 -#include "maincore.h"
     24 -#include "dsp/dspcommands.h"
     18 -#include "gui/crightclickenabler.h"
...

@@ -25,10 +25,9 @@
#include "dsp/channelsamplesink.h"
#include "dsp/nco.h"
#include "dsp/interpolator.h"
#include "util/movingaverage.h"
#include "util/message.h"
Copy link
Owner

@f4exb f4exb Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no reference of the Message class in either the .h or the corresponding .cpp so I do not see the point of this

Edit: it should be added where it is used i.e. adsbdemodworker.h

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ha ta add #include "util/message.h" also in adsbdemodsinkworker.h

@@ -17,9 +17,9 @@

#include <algorithm>

#include "bladerf2/devicebladerf2shared.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should replace it with "bladerf2/devicebladerf2.h" here and not add "bladerf2mimo.h" later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#include "aptdemodsettingsdialog.h"
#include "aptdemodselectdialog.h"

#include "SWGMapItem.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be removed.

#include "util/messagequeue.h"

#include "atvmodreport.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

#include "device/deviceapi.h"
#include "util/sha512.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

#include "SWGXtrxMIMOReport.h"

#include "device/deviceapi.h"
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "dsp/dspdevicemimoengine.h"
#include "dsp/devicesamplesource.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

@@ -21,7 +21,6 @@
///////////////////////////////////////////////////////////////////////////////////

#include "SWGDeviceSettings.h"
#include "soapysdrinput.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

@@ -25,7 +25,6 @@
#include <Tle.h>

#include "satelliteselectiondialog.h"
#include "util/units.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

#include "dsp/dspdevicesourceengine.h"
#include "dsp/dspdevicesinkengine.h"
#include "device/deviceset.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

#include "device/deviceset.h"
#include "settings/mainsettings.h"
#include "settings/preset.h"
#include "maincore.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

@@ -21,11 +21,6 @@
#include <QPushButton>
#include <QCheckBox>

#include "device/deviceset.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

#include "device/deviceapi.h"
#include "device/deviceuiset.h"
#include "gui/colormapper.h"
#include "gui/glspectrum.h"
#include "gui/basicdevicesettingsdialog.h"
#include "gui/dialpopup.h"
#include "gui/dialogpositioner.h"
#include "dsp/dspengine.h"
#include "dsp/dspdevicemimoengine.h"
#include "dsp/dspcommands.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not remove this one

#include "channel/channelwebapiutils.h"
#include "feature/featureset.h"
#include "feature/featureuiset.h"
#include "feature/featureutils.h"
#include "feature/featurewebapiutils.h"
#include "gui/basicfeaturesettingsdialog.h"
#include "gui/dialogpositioner.h"
#include "mainwindow.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace with maincore.h

@@ -27,19 +27,14 @@
#include <QtCharts/QDateTimeAxis>
#include <QtCharts/QValueAxis>

#include "device/deviceapi.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not remove this one

@@ -27,19 +27,14 @@
#include <QtCharts/QDateTimeAxis>
#include <QtCharts/QValueAxis>

#include "device/deviceapi.h"
#include "device/deviceset.h"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not remove this one

@f4exb
Copy link
Owner

f4exb commented Apr 10, 2024

To summarize missing includes still:

diff --git a/plugins/channeltx/modatv/atvmodsource.cpp b/plugins/channeltx/modatv/atvmodsource.cpp                                                                                                                                          
index 92cbb14db..e4bd6fdc8 100644                                                                                                                                                                                                           
--- a/plugins/channeltx/modatv/atvmodsource.cpp                                                                                                                                                                                             
+++ b/plugins/channeltx/modatv/atvmodsource.cpp                                                                                                                                                                                             
@@ -28,6 +28,7 @@                                                                                                                                                                                                                           
                                                                                                                                                                                                                                            
 #include "util/messagequeue.h"                                                                                                                                                                                                             
                                                                                                                                                                                                                                            
+#include "atvmodreport.h"                                                                                                                                                                                                                  
 #include "atvmodsource.h"                                                                                                                                                                                                                  
                                                                                                                                                                                                                                            
 const float ATVModSource::m_blackLevel = 0.3f;                                                                                                                                                                                             
diff --git a/plugins/feature/limerfe/limerfegui.cpp b/plugins/feature/limerfe/limerfegui.cpp                                                                                                                                                
index 4205510b3..2dcab36cc 100644                                                                                                                                                                                                           
--- a/plugins/feature/limerfe/limerfegui.cpp                                                                                                                                                                                                
+++ b/plugins/feature/limerfe/limerfegui.cpp                                                                                                                                                                                                
@@ -22,6 +22,7 @@                                                                                                                                                                                                                           
 #include "util/db.h"                                                                                                                                                                                                                       
 #include "dsp/dspdevicesourceengine.h"                                                                                                                                                                                                     
 #include "dsp/dspdevicesinkengine.h"                                                                                                                                                                                                       
+#include "device/deviceset.h"                                                                                                                                                                                                              
 #include "maincore.h"                                                                                                                                                                                                                      
                                                                                                                                                                                                                                            
 #include "limerfeusbcalib.h"                                                                                                                                                                                                               
diff --git a/plugins/feature/satellitetracker/satelliteradiocontroldialog.cpp b/plugins/feature/satellitetracker/satelliteradiocontroldialog.cpp                                                                                            
index f2300c5b5..6845ebb77 100644                                                                                                                                                                                                           
--- a/plugins/feature/satellitetracker/satelliteradiocontroldialog.cpp                                                                                                                                                                      
+++ b/plugins/feature/satellitetracker/satelliteradiocontroldialog.cpp                                                                                                                                                                      
@@ -21,6 +21,9 @@                                                                                                                                                                                                                           
 #include <QPushButton>                                                                                                                                                                                                                     
 #include <QCheckBox>                                                                                                                                                                                                                       
                                                                                                                                                                                                                                            
+#include "device/deviceset.h"                                                                                                                                                                                                              
+#include "maincore.h"                                                                                                                                                                                                                      
+                                                                                                                                                                                                                                           
 #include "satelliteradiocontroldialog.h"                                                                                                                                                                                                   
                                                                                                                                                                                                                                            
 SatelliteRadioControlDialog::SatelliteRadioControlDialog(SatelliteTrackerSettings *settings,                                                                                                                                               
diff --git a/plugins/feature/satellitetracker/satelliteselectiondialog.cpp b/plugins/feature/satellitetracker/satelliteselectiondialog.cpp                                                                                                  
index be12b45e5..7b6de3e91 100644                                                                                                                                                                                                           
--- a/plugins/feature/satellitetracker/satelliteselectiondialog.cpp                                                                                                                                                                         
+++ b/plugins/feature/satellitetracker/satelliteselectiondialog.cpp                                                                                                                                                                         
@@ -24,6 +24,7 @@                                                                                                                                                                                                                           
 #include <OrbitalElements.h>                                                                                                                                                                                                               
 #include <Tle.h>                                                                                                                                                                                                                           
                                                                                                                                                                                                                                            
+#include "util/units.h"                                                                                                                                                                                                                    
 #include "satelliteselectiondialog.h"                                                                                                                                                                                                      
                                                                                                                                                                                                                                            
 using namespace libsgp4;                                                                                                                                                                                                                   
diff --git a/plugins/feature/satellitetracker/satellitetrackergui.cpp b/plugins/feature/satellitetracker/satellitetrackergui.cpp                                                                                                            
index 52fc01dcb..807f1d5ed 100644                                                                                                                                                                                                           
--- a/plugins/feature/satellitetracker/satellitetrackergui.cpp                                                                                                                                                                              
+++ b/plugins/feature/satellitetracker/satellitetrackergui.cpp                                                                                                                                                                              
@@ -35,6 +35,9 @@                                                                                                                                                                                                                           
 #include "gui/basicfeaturesettingsdialog.h"                                                                                                                                                                                                
 #include "gui/dialogpositioner.h"                                                                                                                                                                                                          
 #include "util/units.h"                                                                                                                                                                                                                    
+#include "device/deviceapi.h"                                                                                                                                                                                                              
+#include "device/deviceset.h"                                                                                                                                                                                                              
+#include "maincore.h"                                                                                                                                                                                                                      
                                                                                                                                                                                                                                            
 #include "ui_satellitetrackergui.h"                                                                                                                                                                                                        
 #include "satellitetracker.h"                                                                                                                                                                                                              
diff --git a/plugins/feature/satellitetracker/satellitetrackersettingsdialog.cpp b/plugins/feature/satellitetracker/satellitetrackersettingsdialog.cpp                                                                                      
index cc53c6158..229458a7a 100644                                                                                                                                                                                                           
--- a/plugins/feature/satellitetracker/satellitetrackersettingsdialog.cpp                                                                                                                                                                   
+++ b/plugins/feature/satellitetracker/satellitetrackersettingsdialog.cpp                                                                                                                                                                   
@@ -15,6 +15,7 @@                                                                                                                                                                                                                           
 // along with this program. If not, see <http://www.gnu.org/licenses/>.          //                                                                                                                                                        
 ///////////////////////////////////////////////////////////////////////////////////                                                                                                                                                        
                                                                                                                                                                                                                                            
+#include "util/units.h"                                                                                                                                                                                                                    
 #include "satellitetrackersettingsdialog.h"                                                                                                                                                                                                
 #include <QDebug>                                                                                                                                                                                                                          
                                                                                                                                                                                                                                            
diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp b/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp                                                                                                                                            
index 028df6c75..3a4e90166 100644                                                                                                                                                                                                           
--- a/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp                                                                                                                                                                                              
+++ b/plugins/samplemimo/xtrxmimo/xtrxmimo.cpp                                                                                                                                                                                              
@@ -29,6 +29,7 @@                                                                                                                                                                                                                           
 #include "device/deviceapi.h"                                                                                                                                                                                                              
 #include "dsp/dspcommands.h"                                                                                                                                                                                                               
 #include "dsp/devicesamplesink.h"                                                                                                                                                                                                          
+#include "dsp/devicesamplesource.h"                                                                                                                                                                                                        
 #include "xtrx/devicextrxparam.h"                                                                                                                                                                                                          
 #include "xtrx/devicextrxshared.h"                                                                                                                                                                                                         
 #include "xtrx/devicextrx.h"                                                                                                                                                                                                               
diff --git a/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp b/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp                                                                                                                                      
index c54563d74..168ad995d 100644                                                                                                                                                                                                           
--- a/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp                                                                                                                                                                                           
+++ b/plugins/samplemimo/xtrxmimo/xtrxmimogui.cpp                                                                                                                                                                                           
@@ -31,6 +31,7 @@                                                                                                                                                                                                                           
 #include "gui/dialpopup.h"                                                                                                                                                                                                                 
 #include "gui/dialogpositioner.h"                                                                                                                                                                                                          
 #include "dsp/devicesamplestatic.h"                                                                                                                                                                                                        
+#include "dsp/dspcommands.h"                                                                                                                                                                                                               
 #include "xtrx/devicextrxshared.h"                                                                                                                                                                                                         
                                                                                                                                                                                                                                            
 #include "xtrxmimo.h"                                                                                                                                                                                                                      
diff --git a/plugins/samplesource/sigmffileinput/sigmffileinput.cpp b/plugins/samplesource/sigmffileinput/sigmffileinput.cpp                                                                                                                
index 70d65a78e..b9d3516fc 100644                                                                                                                                                                                                           
--- a/plugins/samplesource/sigmffileinput/sigmffileinput.cpp                                                                                                                                                                                
+++ b/plugins/samplesource/sigmffileinput/sigmffileinput.cpp                                                                                                                                                                                
@@ -38,6 +38,7 @@                                                                                                                                                                                                                           
 #include "dsp/dspcommands.h"                                                                                                                                                                                                               
 #include "dsp/dspdevicesourceengine.h"                                                                                                                                                                                                     
 #include "device/deviceapi.h"                                                                                                                                                                                                              
+#include "util/sha512.h"                                                                                                                                                                                                                   
                                                                                                                                                                                                                                            
 #include "sigmffileinput.h"                                                                                                                                                                                                                
 #include "sigmffileinputworker.h"                                                                                                                                                                                                          
diff --git a/plugins/samplesource/soapysdrinput/soapysdrinputwebapiadapter.cpp b/plugins/samplesource/soapysdrinput/soapysdrinputwebapiadapter.cpp                                                                                          
index 6fb48044f..e8285d9fc 100644                                                                                                                                                                                                           
--- a/plugins/samplesource/soapysdrinput/soapysdrinputwebapiadapter.cpp                                                                                                                                                                     
+++ b/plugins/samplesource/soapysdrinput/soapysdrinputwebapiadapter.cpp                                                                                                                                                                     
@@ -21,6 +21,7 @@                                                                                                                                                                                                                           
 ///////////////////////////////////////////////////////////////////////////////////                                                                                                                                                        
                                                                                                                                                                                                                                            
 #include "SWGDeviceSettings.h"                                                                                                                                                                                                             
+#include "soapysdrinput.h"                                                                                                                                                                                                                 
 #include "soapysdrinputwebapiadapter.h"                                                                                                                                                                                                    
                                                                                                                                                                                                                                            
 SoapySDRInputWebAPIAdapter::SoapySDRInputWebAPIAdapter()    

adsbdemodsink.h was getting the definition of class Message from dsp/dspcommands.h
which was included by adsbdemodsink.cpp before including adsbdemodsink.h itself.
@dforsi
Copy link
Contributor Author

dforsi commented Apr 11, 2024

Thank you Edouard for your help and your patience.

At first I didn't re-run cmake after installing some dependencies I was missing, otherwise I could have catched some obvious compiler errors. I wonder why the IDE was showing wrongs hints about unused includes, it may be due to stale files in my build directory.

Fixes:
/Users/runner/work/sdrangel/sdrangel/plugins/channelrx/demoddsc/dscdemodgui.cpp:469:9: error: unknown type name 'QRegExp'
@f4exb f4exb merged commit 0cd8800 into f4exb:master Apr 12, 2024
2 of 3 checks passed
@dforsi dforsi deleted the fix/includes branch April 12, 2024 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants