Kaydet (Commit) eea6d395 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:unnecessaryparen

look for  statements like

    return (function());

Change-Id: I906cf2183489f87225b99b987caca67e39b26cc3
Reviewed-on: https://gerrit.libreoffice.org/41260Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 05018699
......@@ -302,7 +302,7 @@ const OUString& MediaWindowImpl::getURL() const
bool MediaWindowImpl::isValid() const
{
return( mxPlayer.is() );
return mxPlayer.is();
}
Size MediaWindowImpl::getPreferredSize() const
......
......@@ -55,6 +55,7 @@ public:
bool VisitDoStmt(const DoStmt *);
bool VisitWhileStmt(const WhileStmt *);
bool VisitSwitchStmt(const SwitchStmt *);
bool VisitReturnStmt(const ReturnStmt* );
bool VisitCallExpr(const CallExpr *);
bool TraverseUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *);
bool TraverseCaseStmt(CaseStmt *);
......@@ -162,6 +163,37 @@ bool UnnecessaryParen::VisitSwitchStmt(const SwitchStmt* switchStmt)
return true;
}
bool UnnecessaryParen::VisitReturnStmt(const ReturnStmt* returnStmt)
{
if (ignoreLocation(returnStmt))
return true;
if (returnStmt->getLocStart().isMacroID())
return true;
if (!returnStmt->getRetValue())
return true;
auto parenExpr = dyn_cast<ParenExpr>(returnStmt->getRetValue()->IgnoreImpCasts());
if (!parenExpr)
return true;
if (parenExpr->getLocStart().isMacroID())
return true;
// assignments need extra parentheses or they generate a compiler warning
auto binaryOp = dyn_cast<BinaryOperator>(parenExpr->getSubExpr());
if (binaryOp && binaryOp->getOpcode() == BO_Assign)
return true;
// only non-operator-calls for now
auto subExpr = parenExpr->getSubExpr();
if (isa<CallExpr>(subExpr) && !isa<CXXOperatorCallExpr>(subExpr))
{
report(
DiagnosticsEngine::Warning, "parentheses immediately inside return statement",
parenExpr->getLocStart())
<< parenExpr->getSourceRange();
}
return true;
}
void UnnecessaryParen::VisitSomeStmt(const Stmt *parent, const Expr* cond, StringRef stmtName)
{
if (ignoreLocation(parent))
......
......@@ -3504,7 +3504,7 @@ OUString SvxIconReplacementDialog::ReplaceIconName( const OUString& rMessage )
sal_uInt16 SvxIconReplacementDialog::ShowDialog()
{
Execute();
return ( GetCurButtonId() );
return GetCurButtonId();
}
/*******************************************************************************
*
......
......@@ -226,7 +226,7 @@ short SvxAreaTabDialog::Ok()
// RET_OK is returned, if at least one
// TabPage returns sal_True in FillItemSet().
// This happens by default at the moment.
return( SfxTabDialog::Ok() );
return SfxTabDialog::Ok();
}
......
......@@ -173,7 +173,7 @@ short SvxLineTabDialog::Ok()
// We return RET_OK if at least one TabPage in FillItemSet() returns sal_True.
// We do this by default at the moment.
return( SfxTabDialog::Ok() );
return SfxTabDialog::Ok();
}
......
......@@ -244,7 +244,7 @@ public:
/** determines whether the database document has an embedded data storage
*/
bool isEmbeddedDatabase() const { return ( m_sConnectURL.startsWith("sdbc:embedded:") ); }
bool isEmbeddedDatabase() const { return m_sConnectURL.startsWith("sdbc:embedded:"); }
/** stores the embedded storage ("database")
......
......@@ -231,7 +231,7 @@ namespace drawinglayer
return false;
}
return (pA->operator==(*pB));
return pA->operator==(*pB);
}
bool Primitive2DContainer::operator==(const Primitive2DContainer& rB) const
......
......@@ -178,7 +178,7 @@ namespace drawinglayer
return false;
}
return (pA->operator==(*pB));
return pA->operator==(*pB);
}
bool Primitive3DContainer::operator==(const Primitive3DContainer& rB) const
......
......@@ -197,7 +197,7 @@ namespace drawinglayer
bool TransparenceTexturePrimitive3D::operator==(const BasePrimitive3D& rPrimitive) const
{
return (GradientTexturePrimitive3D::operator==(rPrimitive));
return GradientTexturePrimitive3D::operator==(rPrimitive);
}
// provide unique ID
......
......@@ -49,7 +49,7 @@ namespace accessibility
sal_Bool SAL_CALL AccessibleSelectionBase::isAccessibleChildSelected( sal_Int32 nChildIndex )
{
::osl::MutexGuard aGuard( implGetMutex() );
return( OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex ) );
return OCommonAccessibleSelection::isAccessibleChildSelected( nChildIndex );
}
......@@ -70,7 +70,7 @@ namespace accessibility
sal_Int32 SAL_CALL AccessibleSelectionBase::getSelectedAccessibleChildCount( )
{
::osl::MutexGuard aGuard( implGetMutex() );
return( OCommonAccessibleSelection::getSelectedAccessibleChildCount() );
return OCommonAccessibleSelection::getSelectedAccessibleChildCount();
}
......
......@@ -1244,7 +1244,7 @@ sal_Bool SAL_CALL UIConfigurationManager::hasStorage()
if ( m_bDisposed )
throw DisposedException();
return ( m_xDocConfigStorage.is() );
return m_xDocConfigStorage.is();
}
// XUIConfigurationPersistence
......
......@@ -101,7 +101,7 @@ transliteration_commonclass::compareSubstring(
sal_Int32 SAL_CALL
transliteration_commonclass::compareString( const OUString& str1, const OUString& str2 )
{
return( compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength()));
return compareSubstring(str1, 0, str1.getLength(), str2, 0, str2.getLength());
}
OUString SAL_CALL
......
......@@ -123,7 +123,7 @@ public:
void* SAL_CALL getSymbol( const ::rtl::OUString& strSymbolName)
{
return ( osl_getSymbol( m_Module, strSymbolName.pData ) );
return osl_getSymbol( m_Module, strSymbolName.pData );
}
/** Get function address by the function name in the module.
......@@ -140,7 +140,7 @@ public:
*/
oslGenericFunction SAL_CALL getFunctionSymbol( const ::rtl::OUString& ustrFunctionSymbolName ) const
{
return ( osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData ) );
return osl_getFunctionSymbol( m_Module, ustrFunctionSymbolName.pData );
}
/// @since LibreOffice 3.5
......
......@@ -208,7 +208,7 @@ public:
*/
bool SAL_CALL setData(void *pData)
{
return (osl_setThreadKeyData(m_hKey, pData));
return osl_setThreadKeyData(m_hKey, pData);
}
/** Get the data associated with the data key.
......
......@@ -659,7 +659,7 @@ double LwpMiddleLayout::GetGeometryHeight()
LwpLayoutGeometry* pGeo = GetGeometry();
if(pGeo)
{
return ( LwpTools::ConvertFromUnitsToMetric( pGeo->GetHeight() ) );
return LwpTools::ConvertFromUnitsToMetric( pGeo->GetHeight() );
}
else
return -1;
......@@ -674,7 +674,7 @@ double LwpMiddleLayout::GetGeometryWidth()
LwpLayoutGeometry* pGeo = GetGeometry();
if(pGeo)
{
return ( LwpTools::ConvertFromUnitsToMetric( pGeo->GetWidth() ) );
return LwpTools::ConvertFromUnitsToMetric( pGeo->GetWidth() );
}
else
return -1;
......
......@@ -904,8 +904,8 @@ XFContentContainer* LwpPara::AddBulletList(XFContentContainer* pCont)
m_nLevel = nLevel;//for get para level
}
return ( pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
nLevel, m_pBullOver->IsSkip()) );
return pBulletStyleMgr->AddBulletList(pCont, bOrdered, m_aBulletStyleName,
nLevel, m_pBullOver->IsSkip());
}
LwpNumberingOverride* LwpPara::GetParaNumbering()
......
......@@ -201,7 +201,7 @@ RegError ORegKey::getKeyNames(const OUString& keyName,
RegError ORegKey::closeKey(RegKeyHandle hKey)
{
return (m_pRegistry->closeKey(hKey));
return m_pRegistry->closeKey(hKey);
}
......@@ -209,7 +209,7 @@ RegError ORegKey::closeKey(RegKeyHandle hKey)
RegError ORegKey::deleteKey(const OUString& keyName)
{
return (m_pRegistry->deleteKey(this, keyName));
return m_pRegistry->deleteKey(this, keyName);
}
......
......@@ -219,7 +219,7 @@ public:
FormulaError GetErrCode() const { return nErrCode; }
bool HasString() const { return bHasString; }
bool HasMatrix() const { return xMatrix.get(); }
bool HasVarRes() const { return ( xVarRes.is() ); }
bool HasVarRes() const { return xVarRes.is(); }
double GetValue() const { return fValue; }
const OUString& GetString() const { return aString; }
const ScMatrixRef& GetMatrix() const { return xMatrix;}
......
......@@ -1022,7 +1022,7 @@ uno::Reference<XAccessible> ScShapeChildren::GetBackgroundShapeAt(const awt::Poi
::accessibility::AccessibleShape* ScShapeChildren::GetAccShape(const ScShapeChildVec& rShapes, sal_Int32 nIndex) const
{
return (GetAccShape(rShapes[nIndex]));
return GetAccShape(rShapes[nIndex]);
}
void ScShapeChildren::FillShapes(const tools::Rectangle& aPixelPaintRect, const MapMode& aMapMode, sal_uInt8 nRangeId)
......
......@@ -90,7 +90,7 @@ public:
void SetWindow(vcl::Window* pWin) { pWindow = pWin; }
sal_uInt16 GetSlotID() const { return( aSfxRequest.GetSlot() ); }
sal_uInt16 GetSlotID() const { return aSfxRequest.GetSlot(); }
bool IsDetectiveHit( const Point& rLogicPos );
......
......@@ -272,7 +272,7 @@ SfxItemSet& SdStyleSheet::GetItemSet()
if (pSdSheet)
{
return(pSdSheet->GetItemSet());
return pSdSheet->GetItemSet();
}
else
{
......
......@@ -42,7 +42,7 @@ void SdInsertPasteDlg::dispose()
bool SdInsertPasteDlg::IsInsertBefore() const
{
return( m_pRbBefore->IsChecked() );
return m_pRbBefore->IsChecked();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -116,7 +116,7 @@ std::vector<OUString> SdInsertPagesObjsDlg::GetList( const sal_uInt16 nType )
*/
bool SdInsertPagesObjsDlg::IsLink()
{
return( m_pCbxLink->IsChecked() );
return m_pCbxLink->IsChecked();
}
/**
......@@ -124,7 +124,7 @@ bool SdInsertPagesObjsDlg::IsLink()
*/
bool SdInsertPagesObjsDlg::IsRemoveUnnessesaryMasterPages() const
{
return( m_pCbxMasters->IsChecked() );
return m_pCbxMasters->IsChecked();
}
/**
......
......@@ -65,10 +65,10 @@ public:
OUString GetSearchText() const { return m_pSearchEdit->GetText(); }
void SetSearchText( const OUString& _rText ) { m_pSearchEdit->SetText( _rText ); }
bool IsOnlyWholeWords() const { return ( m_pWholeWordsBox->IsChecked() ); }
bool IsMarchCase() const { return ( m_pMatchCaseBox->IsChecked() ); }
bool IsWrapAround() const { return ( m_pWrapAroundBox->IsChecked() ); }
bool IsSearchBackwards() const { return ( m_pBackwardsBox->IsChecked() ); }
bool IsOnlyWholeWords() const { return m_pWholeWordsBox->IsChecked(); }
bool IsMarchCase() const { return m_pMatchCaseBox->IsChecked(); }
bool IsWrapAround() const { return m_pWrapAroundBox->IsChecked(); }
bool IsSearchBackwards() const { return m_pBackwardsBox->IsChecked(); }
void SetFocusOnEdit();
......
......@@ -401,7 +401,7 @@ isPartOfType(struct DocumentMetadataAccess_Impl const & i_rImpl,
getURI<rdf::URIs::RDF_TYPE>(i_rImpl.m_xContext),
i_xType.get()),
uno::UNO_SET_THROW);
return (xEnum->hasMoreElements());
return xEnum->hasMoreElements();
} catch (const uno::RuntimeException &) {
throw;
} catch (const uno::Exception & e) {
......
......@@ -142,7 +142,7 @@ private:
inline bool OStorePageManager::isValid() const
{
return (base::isValid() /* @@@ NYI && (m_aRoot.is()) */);
return base::isValid() /* @@@ NYI && (m_aRoot.is()) */;
}
template<> inline OStorePageManager*
......
......@@ -639,7 +639,7 @@ void TransferableHelper::ClearFormats()
bool TransferableHelper::SetAny( const Any& rAny )
{
maAny = rAny;
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -661,7 +661,7 @@ bool TransferableHelper::SetString( const OUString& rString, const DataFlavor& r
else
maAny <<= rString;
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -689,7 +689,7 @@ bool TransferableHelper::SetBitmapEx( const BitmapEx& rBitmapEx, const DataFlavo
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -703,7 +703,7 @@ bool TransferableHelper::SetGDIMetaFile( const GDIMetaFile& rMtf )
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -719,7 +719,7 @@ bool TransferableHelper::SetGraphic( const Graphic& rGraphic )
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
}
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -731,7 +731,7 @@ bool TransferableHelper::SetImageMap( const ImageMap& rIMap )
rIMap.Write( aMemStm );
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -744,7 +744,7 @@ bool TransferableHelper::SetTransferableObjectDescriptor( const TransferableObje
WriteTransferableObjectDescriptor( aMemStm, rDesc );
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Tell() );
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -833,7 +833,7 @@ bool TransferableHelper::SetINetBookmark( const INetBookmark& rBmk,
break;
}
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -847,7 +847,7 @@ bool TransferableHelper::SetINetImage( const INetImage& rINtImg,
maAny <<= Sequence< sal_Int8 >( static_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
return( maAny.hasValue() );
return maAny.hasValue();
}
......@@ -877,7 +877,7 @@ bool TransferableHelper::SetObject( void* pUserObject, SotClipboardFormatId nUse
maAny <<= aSeq;
}
return( maAny.hasValue() );
return maAny.hasValue();
}
......
......@@ -382,12 +382,12 @@ void GalleryIconView::KeyInput(const KeyEvent& rKEvt)
sal_Int8 GalleryIconView::AcceptDrop(const AcceptDropEvent& /*rEvt*/)
{
return(static_cast<GalleryBrowser2*>(GetParent())->AcceptDrop(*this));
return static_cast<GalleryBrowser2*>(GetParent())->AcceptDrop(*this);
}
sal_Int8 GalleryIconView::ExecuteDrop(const ExecuteDropEvent& rEvt)
{
return(static_cast<GalleryBrowser2*>(GetParent())->ExecuteDrop(rEvt));
return static_cast<GalleryBrowser2*>(GetParent())->ExecuteDrop(rEvt);
}
void GalleryIconView::StartDrag(sal_Int8, const Point&)
......@@ -592,7 +592,7 @@ sal_Int8 GalleryListView::ExecuteDrop( const BrowserExecuteDropEvent& rEvt )
aEvt.maPosPixel.Y() += GetTitleHeight();
return( static_cast<GalleryBrowser2*>( GetParent() )->ExecuteDrop( aEvt ) );
return static_cast<GalleryBrowser2*>( GetParent() )->ExecuteDrop( aEvt );
}
void GalleryListView::StartDrag( sal_Int8, const Point& rPosPixel )
......
......@@ -856,7 +856,7 @@ inline SwPaM* SwCursorShell::GetStackCursor() const { return m_pStackCursor; }
inline void SwCursorShell::SetMark() { m_pCurrentCursor->SetMark(); }
inline bool SwCursorShell::HasMark() { return( m_pCurrentCursor->HasMark() ); }
inline bool SwCursorShell::HasMark() { return m_pCurrentCursor->HasMark(); }
inline bool SwCursorShell::IsSelection() const
{
......
......@@ -627,7 +627,7 @@ bool SwView::IsFormMode() const
{
if (GetDrawFuncPtr() && GetDrawFuncPtr()->IsCreateObj())
{
return (GetDrawFuncPtr()->IsInsertForm());
return GetDrawFuncPtr()->IsInsertForm();
}
return AreOnlyFormsSelected();
......
......@@ -507,8 +507,8 @@ extern "C"
{
static int SAL_CALL ComponentInfoCompare( const void* pFirst, const void* pSecond)
{
return( strcmp( static_cast<ComponentInfo const *>(pFirst)->pName,
static_cast<ComponentInfo const *>(pSecond)->pName ) );
return strcmp( static_cast<ComponentInfo const *>(pFirst)->pName,
static_cast<ComponentInfo const *>(pSecond)->pName );
}
}
......
......@@ -353,7 +353,7 @@ bool ContentProperties::containsAllNames(
}
}
return ( rNamesNotContained.empty() );
return rNamesNotContained.empty();
}
......
......@@ -308,7 +308,7 @@ Type SAL_CALL GlobalEventConfig_Impl::getElementType( )
bool SAL_CALL GlobalEventConfig_Impl::hasElements( )
{
return ( m_eventBindingHash.empty() );
return m_eventBindingHash.empty();
}
// and now the wrapper
......
......@@ -87,7 +87,7 @@ TextAttrib* TextAttribProtect::Clone() const
bool TextAttribProtect::operator==( const TextAttrib& rAttr ) const
{
return ( TextAttrib::operator==(rAttr ) );
return TextAttrib::operator==(rAttr );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -73,7 +73,7 @@ const sal_uInt8* GfxLink::GetData() const
if( IsSwappedOut() )
const_cast<GfxLink*>(this)->SwapIn();
return( mpSwapInData.get() );
return mpSwapInData.get();
}
......
......@@ -163,7 +163,7 @@ bool OutputDevice::IsNativeControlSupported( ControlType nType, ControlPart nPar
if ( !AcquireGraphics() )
return false;
return( mpGraphics->IsNativeControlSupported(nType, nPart) );
return mpGraphics->IsNativeControlSupported(nType, nPart);
}
bool OutputDevice::HitTestNativeScrollbar(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment