2015-07-02 09:18:31 +02:00
#!/usr/bin/python
import sys
2015-09-30 10:29:19 +02:00
import re
2015-10-02 08:37:23 +02:00
import io
2015-07-02 09:18:31 +02:00
2016-05-25 11:28:58 +02:00
# --------------------------------------------------------------------------------------------
# globals
# --------------------------------------------------------------------------------------------
definitionSet = set ( ) # set of tuple(return_type, name_and_params)
2015-09-30 10:29:19 +02:00
definitionToSourceLocationMap = dict ( )
2016-05-25 11:28:58 +02:00
# for the "unused methods" analysis
callSet = set ( ) # set of tuple(return_type, name_and_params)
2016-10-17 15:34:04 +02:00
# for the "method can be private" analysis
2016-05-25 11:28:58 +02:00
publicDefinitionSet = set ( ) # set of tuple(return_type, name_and_params)
calledFromOutsideSet = set ( ) # set of tuple(return_type, name_and_params)
2016-11-21 15:36:08 +02:00
virtualSet = set ( ) # set of tuple(return_type, name_and_params)
2016-05-25 11:28:58 +02:00
# for the "unused return types" analysis
usedReturnSet = set ( ) # set of tuple(return_type, name_and_params)
2016-02-01 14:52:38 +02:00
2015-07-02 09:18:31 +02:00
# things we need to exclude for reasons like :
# - it's a weird template thingy that confuses the plugin
2016-05-25 11:28:58 +02:00
unusedMethodsExclusionSet = set ( [
2015-07-08 10:25:58 +02:00
# only used by Windows build
2015-07-02 09:18:31 +02:00
" _Bool basegfx::B2ITuple::equalZero() const " ,
" class basegfx::B2DPolyPolygon basegfx::unotools::UnoPolyPolygon::getPolyPolygonUnsafe() const " ,
2015-07-28 08:39:57 +02:00
" void basegfx::B2IRange::expand(const class basegfx::B2IRange &) " ,
2015-07-07 13:58:41 +02:00
" void OpenGLContext::requestSingleBufferedRendering() " ,
" _Bool TabitemValue::isBothAligned() const " ,
" _Bool TabitemValue::isNotAligned() const " ,
2016-05-31 08:47:19 +02:00
" void TabitemValue::isLast() const " ,
2015-07-07 13:58:41 +02:00
" void StyleSettings::SetSpinSize(long) " ,
" void StyleSettings::SetFloatTitleHeight(long) " ,
" void StyleSettings::SetTitleHeight(long) " ,
" void StyleSettings::SetUseFlatBorders(_Bool) " ,
" void StyleSettings::SetUseFlatMenus(_Bool) " ,
" void StyleSettings::SetCursorSize(long) " ,
" _Bool CommandMediaData::GetPassThroughToOS() const " ,
" void Application::AppEvent(const class ApplicationEvent &) " ,
2015-07-08 10:25:58 +02:00
" int PhysicalFontFace::GetWidth() const " ,
" void PhysicalFontFace::SetBitmapSize(int,int) " ,
2015-07-28 08:39:57 +02:00
" class boost::intrusive_ptr<class FontCharMap> FontCharMap::GetDefaultMap(_Bool) " ,
2015-07-08 10:25:58 +02:00
" _Bool SalObject::IsEraseBackgroundEnabled() " ,
2015-07-14 14:04:41 +02:00
" const class rtl::OUString & connectivity::OColumn::getCatalogName() const " ,
" const class rtl::OUString & connectivity::OColumn::getSchemaName() const " ,
" _Bool connectivity::OColumn::isDefinitelyWritable() const " ,
" _Bool connectivity::OColumn::isReadOnly() const " ,
" _Bool connectivity::OColumn::isWritable() const " ,
2015-07-21 10:44:17 +02:00
" _Bool IDocumentLinksAdministration::GetData(const class rtl::OUString &,const class rtl::OUString &,class com::sun::star::uno::Any &) const " ,
" _Bool IDocumentLinksAdministration::SetData(const class rtl::OUString &,const class rtl::OUString &,const class com::sun::star::uno::Any &) " ,
2015-07-22 10:20:03 +02:00
" _Bool ScImportExport::ImportData(const class rtl::OUString &,const class com::sun::star::uno::Any &) " ,
2015-07-23 09:49:57 +02:00
" void* ScannerManager::GetData() " ,
" void ScannerManager::SetData(void *) " ,
2017-03-29 11:41:17 +02:00
" class rtl::OUString FilterConfigCache::GetImportFormatMediaType(unsigned short) " ,
2015-07-08 10:25:58 +02:00
# only used by OSX build
" void StyleSettings::SetHideDisabledMenuItems(_Bool) " ,
2017-03-29 11:41:17 +02:00
" _Bool TabitemValue::isLast() const " ,
" ApplicationEvent::ApplicationEvent(enum ApplicationEvent::Type,const class std::__debug::vector<class rtl::OUString, class std::allocator<class rtl::OUString> > &) " ,
2015-07-20 16:03:50 +02:00
# debugging methods
" void oox::drawingml::TextParagraphProperties::dump() const " ,
2015-07-28 08:39:57 +02:00
" void oox::PropertyMap::dumpCode(class com::sun::star::uno::Reference<class com::sun::star::beans::XPropertySet>) " ,
" void oox::PropertyMap::dumpData(class com::sun::star::uno::Reference<class com::sun::star::beans::XPropertySet>) " ,
2015-07-20 16:03:50 +02:00
" class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> > writerfilter::ooxml::OOXMLPropertySet::toString() " ,
2015-07-21 10:44:17 +02:00
# I need to teach the plugin that for loops with range expressions call begin() and end()
" class __gnu_debug::_Safe_iterator<class __gnu_cxx::__normal_iterator<class SwAnchoredObject *const *, class std::__cxx1998::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > >, class std::__debug::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > > SwSortedObjs::begin() const " ,
" class __gnu_debug::_Safe_iterator<class __gnu_cxx::__normal_iterator<class SwAnchoredObject *const *, class std::__cxx1998::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > >, class std::__debug::vector<class SwAnchoredObject *, class std::allocator<class SwAnchoredObject *> > > SwSortedObjs::end() const " ,
2015-09-30 10:29:19 +02:00
# loaded by dlopen()
" void * getStandardAccessibleFactory() " ,
" void * getSvtAccessibilityComponentFactory() " ,
2016-11-06 01:19:01 +03:00
" struct _rtl_uString * basicide_choose_macro(void *,void *,unsigned char,struct _rtl_uString *) " ,
2015-09-30 10:29:19 +02:00
" void basicide_macro_organizer(short) " ,
" long basicide_handle_basic_error(void *) " ,
" class com::sun::star::uno::XInterface * org_libreoffice_chart2_Chart2ToolboxController(class com::sun::star::uno::XComponentContext *,const class com::sun::star::uno::Sequence<class com::sun::star::uno::Any> &) " ,
" class com::sun::star::uno::XInterface * org_libreoffice_comp_chart2_sidebar_ChartPanelFactory(class com::sun::star::uno::XComponentContext *,const class com::sun::star::uno::Sequence<class com::sun::star::uno::Any> &) " ,
" class chart::opengl::OpenglShapeFactory * getOpenglShapeFactory() " ,
" class VclAbstractDialogFactory * CreateDialogFactory() " ,
" _Bool GetSpecialCharsForEdit(class vcl::Window *,const class vcl::Font &,class rtl::OUString &) " ,
2015-10-02 08:37:23 +02:00
" const struct ImplTextEncodingData * sal_getFullTextEncodingData(unsigned short) " ,
" class SalInstance * create_SalInstance() " ,
" class SwAbstractDialogFactory * SwCreateDialogFactory() " ,
" class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface> WordPerfectImportFilterDialog_createInstance(const class com::sun::star::uno::Reference<class com::sun::star::uno::XComponentContext> &) " ,
" class UnoWrapperBase * CreateUnoWrapper() " ,
" class SwAbstractDialogFactory * SwCreateDialogFactory() " ,
" unsigned long GetSaveWarningOfMSVBAStorage_ww8(class SfxObjectShell &) " ,
" unsigned long SaveOrDelMSVBAStorage_ww8(class SfxObjectShell &,class SotStorage &,unsigned char,const class rtl::OUString &) " ,
" void ExportRTF(const class rtl::OUString &,const class rtl::OUString &,class tools::SvRef<class Writer> &) " ,
" void ExportDOC(const class rtl::OUString &,const class rtl::OUString &,class tools::SvRef<class Writer> &) " ,
" class Reader * ImportRTF() " ,
" void ImportXE(class SwDoc &,class SwPaM &,const class rtl::OUString &) " ,
" _Bool TestImportDOC(const class rtl::OUString &,const class rtl::OUString &) " ,
" class vcl::Window * CreateWindow(class VCLXWindow **,const struct com::sun::star::awt::WindowDescriptor *,class vcl::Window *,long) " ,
2015-10-07 16:28:27 +02:00
# only used when the ODBC driver is enabled
" _Bool getImplementation(type-parameter-?-? *&,const class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface> &) " ,
2017-03-29 11:41:17 +02:00
# called from extensions
" unsigned short MenuBar::AddMenuBarButton(const class Image &,const class Link<struct MenuBar::MenuBarButtonCallbackArg &, _Bool> &,const class rtl::OUString &) " ,
" void MenuBar::SetMenuBarButtonHighlightHdl(unsigned short,const class Link<struct MenuBar::MenuBarButtonCallbackArg &, _Bool> &) " ,
" class Rectangle MenuBar::GetMenuBarButtonRectPixel(unsigned short) " ,
" void MenuBar::RemoveMenuBarButton(unsigned short) " ,
2015-07-02 09:18:31 +02:00
] )
2015-10-27 01:59:25 +01:00
# clang does not always use exactly the same numbers in the type-parameter vars it generates
# so I need to substitute them to ensure we can match correctly.
normalizeTypeParamsRegex = re . compile ( r " type-parameter- \ d+- \ d+ " )
def normalizeTypeParams ( line ) :
return normalizeTypeParamsRegex . sub ( " type-parameter-?-? " , line )
2015-07-02 09:18:31 +02:00
2016-05-25 11:28:58 +02:00
# --------------------------------------------------------------------------------------------
# primary input loop
# --------------------------------------------------------------------------------------------
2015-09-30 10:29:19 +02:00
# The parsing here is designed to avoid grabbing stuff which is mixed in from gbuild.
2015-07-06 10:44:18 +02:00
# I have not yet found a way of suppressing the gbuild output.
2016-07-25 13:22:38 +02:00
with io . open ( " loplugin.unusedmethods.log " , " rb " , buffering = 1024 * 1024 ) as txt :
2015-07-02 09:18:31 +02:00
for line in txt :
2016-09-15 08:49:53 +02:00
tokens = line . strip ( ) . split ( " \t " )
if tokens [ 0 ] == " definition: " :
access = tokens [ 1 ]
returnType = tokens [ 2 ]
nameAndParams = tokens [ 3 ]
sourceLocation = tokens [ 4 ]
2016-11-21 15:36:08 +02:00
virtual = " "
if len ( tokens ) > = 6 : virtual = tokens [ 5 ]
2016-02-01 14:52:38 +02:00
funcInfo = ( normalizeTypeParams ( returnType ) , normalizeTypeParams ( nameAndParams ) )
2015-09-30 10:29:19 +02:00
definitionSet . add ( funcInfo )
2016-02-01 14:52:38 +02:00
if access == " public " :
publicDefinitionSet . add ( funcInfo )
definitionToSourceLocationMap [ funcInfo ] = sourceLocation
2016-11-21 15:36:08 +02:00
if virtual == " virtual " :
virtualSet . add ( funcInfo )
2016-09-15 08:49:53 +02:00
elif tokens [ 0 ] == " call: " :
returnType = tokens [ 1 ]
nameAndParams = tokens [ 2 ]
2016-02-01 14:52:38 +02:00
callSet . add ( ( normalizeTypeParams ( returnType ) , normalizeTypeParams ( nameAndParams ) ) )
2016-09-15 08:49:53 +02:00
elif tokens [ 0 ] == " usedReturn: " :
returnType = tokens [ 1 ]
nameAndParams = tokens [ 2 ]
2016-02-01 14:52:38 +02:00
usedReturnSet . add ( ( normalizeTypeParams ( returnType ) , normalizeTypeParams ( nameAndParams ) ) )
2016-09-22 13:12:47 +02:00
elif tokens [ 0 ] == " outside: " :
2016-09-15 08:49:53 +02:00
returnType = tokens [ 1 ]
nameAndParams = tokens [ 2 ]
2016-02-01 14:52:38 +02:00
calledFromOutsideSet . add ( ( normalizeTypeParams ( returnType ) , normalizeTypeParams ( nameAndParams ) ) )
2016-10-17 15:34:04 +02:00
else :
print ( " unknown line: " + line )
2015-07-02 09:18:31 +02:00
2016-02-01 14:52:38 +02:00
# Invert the definitionToSourceLocationMap.
2015-10-07 16:28:27 +02:00
# If we see more than one method at the same sourceLocation, it's being autogenerated as part of a template
2016-02-01 14:52:38 +02:00
# and we should just ignore it.
2015-10-07 16:28:27 +02:00
sourceLocationToDefinitionMap = { }
for k , v in definitionToSourceLocationMap . iteritems ( ) :
sourceLocationToDefinitionMap [ v ] = sourceLocationToDefinitionMap . get ( v , [ ] )
sourceLocationToDefinitionMap [ v ] . append ( k )
for k , definitions in sourceLocationToDefinitionMap . iteritems ( ) :
if len ( definitions ) > 1 :
for d in definitions :
definitionSet . remove ( d )
2016-01-11 16:02:17 +02:00
def isOtherConstness ( d , callSet ) :
2016-05-25 11:28:58 +02:00
method = d [ 0 ] + " " + d [ 1 ]
2016-01-11 16:02:17 +02:00
# if this method is const, and there is a non-const variant of it, and the non-const variant is in use, then leave it alone
if d [ 0 ] . startswith ( " const " ) and d [ 1 ] . endswith ( " const " ) :
if ( ( d [ 0 ] [ 6 : ] , d [ 1 ] [ : - 6 ] ) in callSet ) :
return True
2016-05-25 11:28:58 +02:00
elif method . endswith ( " const " ) :
method2 = method [ : len ( method ) - 6 ] # strip off " const"
if ( ( d [ 0 ] , method2 ) in callSet ) :
2016-01-11 16:02:17 +02:00
return True
2016-05-25 11:28:58 +02:00
if method . endswith ( " const " ) and ( " ::iterator " in method ) :
method2 = method [ : len ( method ) - 6 ] # strip off " const"
method2 = method2 . replace ( " ::const_iterator " , " ::iterator " )
if ( ( d [ 0 ] , method2 ) in callSet ) :
2016-01-11 16:02:17 +02:00
return True
# if this method is non-const, and there is a const variant of it, and the const variant is in use, then leave it alone
2016-05-25 11:28:58 +02:00
if ( not method . endswith ( " const " ) ) and ( ( d [ 0 ] , " const " + method + " const " ) in callSet ) :
2016-01-11 16:02:17 +02:00
return True
2016-05-25 11:28:58 +02:00
if ( not method . endswith ( " const " ) ) and ( " ::iterator " in method ) :
method2 = method . replace ( " ::iterator " , " ::const_iterator " ) + " const "
if ( ( d [ 0 ] , method2 ) in callSet ) :
2016-01-11 16:02:17 +02:00
return True
return False
2016-05-25 11:28:58 +02:00
# sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
def natural_sort_key ( s , _nsre = re . compile ( ' ([0-9]+) ' ) ) :
return [ int ( text ) if text . isdigit ( ) else text . lower ( )
for text in re . split ( _nsre , s ) ]
def sort_set_by_natural_key ( s ) :
return sorted ( s , key = lambda v : natural_sort_key ( v [ 1 ] ) )
2015-10-07 16:28:27 +02:00
2016-05-25 11:28:58 +02:00
# --------------------------------------------------------------------------------------------
# "unused methods" analysis
# --------------------------------------------------------------------------------------------
2016-01-11 08:41:55 +02:00
2016-05-25 11:28:58 +02:00
tmp1set = set ( ) # set of tuple(method, source_location)
unusedSet = set ( ) # set of tuple(return_type, name_and_params)
2015-09-30 10:29:19 +02:00
for d in definitionSet :
2016-05-25 11:28:58 +02:00
method = d [ 0 ] + " " + d [ 1 ]
if method in unusedMethodsExclusionSet :
2015-09-30 10:29:19 +02:00
continue
if d in callSet :
continue
2016-01-19 09:40:25 +02:00
if isOtherConstness ( d , callSet ) :
2015-07-02 09:18:31 +02:00
continue
2017-03-03 11:27:32 +02:00
# exclude assignment operators, if we remove them, the compiler creates a default one, which can have odd consequences
2016-01-19 09:40:25 +02:00
if " ::operator=( " in d [ 1 ] :
2015-07-02 09:18:31 +02:00
continue
2016-01-19 09:40:25 +02:00
# these are only invoked implicitly, so the plugin does not see the calls
if " ::operator new( " in d [ 1 ] or " ::operator delete( " in d [ 1 ] :
2016-01-11 16:02:17 +02:00
continue
2015-10-02 08:37:23 +02:00
# just ignore iterators, they normally occur in pairs, and we typically want to leave one constness version alone
# alone if the other one is in use.
if d [ 1 ] == " begin() const " or d [ 1 ] == " begin() " or d [ 1 ] == " end() " or d [ 1 ] == " end() const " :
continue
2017-03-25 09:32:57 +01:00
# There is lots of macro magic going on in SRCDIR/include/sax/fshelper.hxx that should be using C++11 varargs templates
2015-09-30 10:29:19 +02:00
if d [ 1 ] . startswith ( " sax_fastparser::FastSerializerHelper:: " ) :
2015-07-02 09:18:31 +02:00
continue
# used by Windows build
2015-09-30 10:29:19 +02:00
if any ( x in d [ 1 ] for x in [ " DdeTopic:: " , " DdeData:: " , " DdeService:: " , " DdeTransaction:: " , " DdeConnection:: " , " DdeLink:: " , " DdeItem:: " , " DdeGetPutItem:: " ] ) :
2015-07-02 09:18:31 +02:00
continue
2016-09-22 16:34:14 +02:00
if method == " class tools::SvRef<class FontCharMap> FontCharMap::GetDefaultMap(_Bool) " :
continue
2015-08-04 16:28:49 +02:00
# too much template magic here for my plugin
2015-09-30 10:29:19 +02:00
if ( ( " cairocanvas:: " in d [ 1 ] )
or ( " canvas:: " in d [ 1 ] )
or ( " oglcanvas:: " in d [ 1 ] )
or ( " vclcanvas:: " in d [ 1 ] ) ) :
2015-08-04 16:28:49 +02:00
continue
2015-09-30 10:29:19 +02:00
# these are loaded by dlopen() from somewhere
if " get_implementation " in d [ 1 ] :
continue
if " component_getFactory " in d [ 1 ] :
continue
if d [ 0 ] == " _Bool " and " _supportsService(const class rtl::OUString &) " in d [ 1 ] :
continue
if ( d [ 0 ] == " class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface> "
and " Instance(const class com::sun::star::uno::Reference<class com::sun::star::lang::XMultiServiceFactory> &) " in d [ 1 ] ) :
continue
# ignore the Java symbols, loaded from the JavaVM
if d [ 1 ] . startswith ( " Java_ " ) :
continue
# ignore external code
if definitionToSourceLocationMap [ d ] . startswith ( " external/ " ) :
continue
# ignore the VCL_BUILDER_DECL_FACTORY stuff
if d [ 0 ] == " void " and d [ 1 ] . startswith ( " make " ) and ( " (class VclPtr<class vcl::Window> & " in d [ 1 ] ) :
continue
2015-10-02 08:37:23 +02:00
# ignore methods used to dump objects to stream - normally used for debugging
if d [ 0 ] == " class std::basic_ostream<char> & " and d [ 1 ] . startswith ( " operator<<(class std::basic_ostream<char> & " ) :
continue
2015-10-07 16:28:27 +02:00
if d [ 0 ] == " basic_ostream<type-parameter-?-?, type-parameter-?-?> & " and d [ 1 ] . startswith ( " operator<<(basic_ostream<type-parameter-?-? " ) :
continue
2016-05-30 15:37:25 +02:00
if " ::operator " in d [ 1 ] :
continue
2016-09-22 16:34:14 +02:00
2016-09-22 15:08:42 +02:00
location = definitionToSourceLocationMap [ d ] ;
# whacky template stuff
if location . startswith ( " sc/source/ui/vba/vbaformat.hxx " ) : continue
2016-09-22 16:34:14 +02:00
# not sure how this stuff is called
if location . startswith ( " include/test " ) : continue
# leave the debug/dump alone
if location . startswith ( " include/oox/dump " ) : continue
2015-09-30 10:29:19 +02:00
2016-05-25 11:28:58 +02:00
unusedSet . add ( d ) # used by the "unused return types" analysis
2016-09-22 15:08:42 +02:00
tmp1set . add ( ( method , location ) )
2015-09-30 10:29:19 +02:00
2016-05-25 11:28:58 +02:00
# print out the results, sorted by name and line number
2016-10-17 15:34:04 +02:00
with open ( " loplugin.unusedmethods.report-unused-methods " , " wt " ) as f :
2016-05-25 11:28:58 +02:00
for t in sort_set_by_natural_key ( tmp1set ) :
2016-02-09 13:37:03 +02:00
f . write ( t [ 1 ] + " \n " )
f . write ( " " + t [ 0 ] + " \n " )
2016-01-11 08:41:55 +02:00
2016-05-25 11:28:58 +02:00
# --------------------------------------------------------------------------------------------
# "unused return types" analysis
# --------------------------------------------------------------------------------------------
2016-01-11 08:41:55 +02:00
tmp2set = set ( )
for d in definitionSet :
2016-05-25 11:28:58 +02:00
method = d [ 0 ] + " " + d [ 1 ]
2016-02-01 14:52:38 +02:00
if d in usedReturnSet :
2016-01-11 08:41:55 +02:00
continue
2016-05-25 11:28:58 +02:00
if d in unusedSet :
continue
2016-02-01 14:52:38 +02:00
if isOtherConstness ( d , usedReturnSet ) :
2016-01-11 16:02:17 +02:00
continue
2016-05-25 11:28:58 +02:00
# ignore methods with no return type, and constructors
if d [ 0 ] == " void " or d [ 0 ] == " " :
2016-01-11 08:41:55 +02:00
continue
2016-01-20 16:36:19 +02:00
# ignore bool returns, provides important documentation in the code
if d [ 0 ] == " _Bool " :
continue
2016-01-11 08:41:55 +02:00
# ignore UNO constructor method entrypoints
2016-01-11 11:22:46 +02:00
if " _get_implementation " in d [ 1 ] or " _getFactory " in d [ 1 ] :
2016-01-11 08:41:55 +02:00
continue
# the plugin can't see calls to these
if " operator new " in d [ 1 ] :
continue
# unused return type is not a problem here
2016-01-11 16:02:17 +02:00
if ( " operator=( " in d [ 1 ] or " operator&= " in d [ 1 ] or " operator|= " in d [ 1 ] or " operator^= " in d [ 1 ]
or " operator+= " in d [ 1 ] or " operator-= " in d [ 1 ]
or " operator<< " in d [ 1 ] or " operator>> " in d [ 1 ]
or " operator++ " in d [ 1 ] or " operator-- " in d [ 1 ] ) :
2016-01-11 08:41:55 +02:00
continue
# ignore external code
if definitionToSourceLocationMap [ d ] . startswith ( " external/ " ) :
continue
2016-09-22 13:12:47 +02:00
# ignore UNO constructor functions
if ( d [ 0 ] == " class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface> " and
d [ 1 ] . endswith ( " _createInstance(const class com::sun::star::uno::Reference<class com::sun::star::lang::XMultiServiceFactory> &) " ) ) :
continue
if ( d [ 0 ] == " class com::sun::star::uno::Reference<class com::sun::star::uno::XInterface> " and
d [ 1 ] . endswith ( " _CreateInstance(const class com::sun::star::uno::Reference<class com::sun::star::lang::XMultiServiceFactory> &) " ) ) :
continue
# debug code
if d [ 1 ] == " writerfilter::ooxml::OOXMLPropertySet::toString() " :
continue
location = definitionToSourceLocationMap [ d ] ;
# windows only
if location . startswith ( " include/svl/svdde.hxx " ) : continue
# fluent API (return ref to self)
if location . startswith ( " include/tools/stream.hxx " ) : continue
tmp2set . add ( ( method , location ) )
2015-09-30 10:29:19 +02:00
2016-05-25 11:28:58 +02:00
# print output, sorted by name and line number
2016-10-17 15:34:04 +02:00
with open ( " loplugin.unusedmethods.report-unused-returns " , " wt " ) as f :
2016-05-25 11:28:58 +02:00
for t in sort_set_by_natural_key ( tmp2set ) :
f . write ( t [ 1 ] + " \n " )
2016-02-09 13:37:03 +02:00
f . write ( " " + t [ 0 ] + " \n " )
2016-02-01 14:52:38 +02:00
2016-05-25 11:28:58 +02:00
# --------------------------------------------------------------------------------------------
2016-10-17 15:34:04 +02:00
# "method can be private" analysis
2016-05-25 11:28:58 +02:00
# --------------------------------------------------------------------------------------------
2016-02-01 14:52:38 +02:00
tmp3set = set ( )
for d in publicDefinitionSet :
2016-05-25 11:28:58 +02:00
method = d [ 0 ] + " " + d [ 1 ]
2016-02-01 14:52:38 +02:00
if d in calledFromOutsideSet :
continue
2016-11-21 15:36:08 +02:00
if d in virtualSet :
continue
2016-11-14 11:32:06 +02:00
# TODO ignore constructors for now, my called-from-outside analysis doesn't work here
if d [ 0 ] == " " :
continue
2016-02-01 14:52:38 +02:00
if isOtherConstness ( d , calledFromOutsideSet ) :
continue
# ignore external code
if definitionToSourceLocationMap [ d ] . startswith ( " external/ " ) :
continue
2016-05-25 11:28:58 +02:00
tmp3set . add ( ( method , definitionToSourceLocationMap [ d ] ) )
2016-02-01 14:52:38 +02:00
2016-05-25 11:28:58 +02:00
# print output, sorted by name and line number
2016-10-17 15:34:04 +02:00
with open ( " loplugin.unusedmethods.report-can-be-private " , " wt " ) as f :
2016-05-25 11:28:58 +02:00
for t in sort_set_by_natural_key ( tmp3set ) :
2016-02-09 13:37:03 +02:00
f . write ( t [ 1 ] + " \n " )
f . write ( " " + t [ 0 ] + " \n " )
2015-07-02 09:18:31 +02:00