zeroc-ice / ice-demos

Sample programs for Ice
https://zeroc.com
GNU General Public License v2.0
323 stars 218 forks source link

Avoid thrown exception type is not nothrow copy constructible [cert-err60-cpp] #146

Open ClausKlein opened 2 years ago

ClausKlein commented 2 years ago

I am evaluating the zeros-ice framework with c++11 enabled mapping on OSX. I use the current ice version v3.7 and check with clang-tidy tools the generated code quality.

To do this, I use this GNUmakefile:

check: compile_commands.json
    run-clang-tidy

compile_commands.json:
    bear -- $(MAKE) -f makefile -j V=1 Chat/client Chat/server
    perl -i.bak -p -e 's#-Wall#-I/usr/local/include#;' $@

.POHNY: all clean distclean
all:
    $(MAKE) -f makefile -j V=1 Chat/client Chat/server

clean:
    $(MAKE) -f makefile -j V=1 Chat/client_clean Chat/server_clean

distclean: clean
    $(MAKE) -f makefile -j V=1 Chat/client_distclean Chat/server_distclean
    $(RM) compile_commands.json *.bak

This is the result:


clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/ChatUtils.cpp
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/ChatUtils.cpp:23:5: warning: use range-based for loop instead [modernize-loop-convert]
    for(unsigned int count = 0; count < sizeof(htmlEntities) / sizeof(htmlEntities[0]); ++count)
    ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       (const auto & htmlEntitie : htmlEntities)
64088 warnings generated.
Suppressed 64087 warnings (64087 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatUtils.cpp
Chat/server/ChatUtils.cpp:49:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Chat::InvalidMessageException(os.str());
              ^
64084 warnings generated.
Suppressed 64083 warnings (64083 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/generated/Chat.cpp
64337 warnings generated.
Suppressed 64337 warnings (64337 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/generated/Chat.cpp
64337 warnings generated.
Suppressed 64337 warnings (64337 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/generated/PollingChat.cpp
Chat/client/generated/PollingChat.cpp:200:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/client/generated/PollingChat.cpp:240:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
Chat/client/generated/PollingChat.cpp:296:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/client/generated/PollingChat.cpp:324:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
70507 warnings generated.
Suppressed 70503 warnings (70503 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/generated/ChatSession.cpp
Chat/client/generated/ChatSession.cpp:190:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/client/generated/ChatSession.cpp:230:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
Chat/client/generated/ChatSession.cpp:300:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/client/generated/ChatSession.cpp:336:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
70845 warnings generated.
Suppressed 70841 warnings (70841 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/generated/PollingChat.cpp
Chat/server/generated/PollingChat.cpp:200:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/server/generated/PollingChat.cpp:240:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
Chat/server/generated/PollingChat.cpp:296:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/server/generated/PollingChat.cpp:324:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
70507 warnings generated.
Suppressed 70503 warnings (70503 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/generated/ChatSession.cpp
Chat/server/generated/ChatSession.cpp:190:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/server/generated/ChatSession.cpp:230:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
Chat/server/generated/ChatSession.cpp:300:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
              ^
Chat/server/generated/ChatSession.cpp:336:19: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
            throw ::Ice::OperationNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
                  ^
70845 warnings generated.
Suppressed 70841 warnings (70841 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/PollingChatSessionI.cpp
Chat/server/PollingChatSessionI.cpp:89:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
Chat/server/PollingChatSessionI.cpp:105:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
Chat/server/PollingChatSessionI.cpp:121:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
Chat/server/PollingChatSessionI.cpp:135:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Chat::InvalidMessageException(ex.what());
              ^
Chat/server/PollingChatSessionI.cpp:151:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
74465 warnings generated.
Suppressed 74460 warnings (74460 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/PollingChatSessionFactoryI.cpp
Chat/server/PollingChatSessionFactoryI.cpp:37:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw PollingChat::CannotCreateSessionException(ex.what());
              ^
74497 warnings generated.
Suppressed 74496 warnings (74496 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/PollingClient.cpp
Chat/client/PollingClient.cpp:22:7: warning: class 'GetUpdatesTask' defines a non-default destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [hicpp-special-member-functions]
class GetUpdatesTask
      ^
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/PollingClient.cpp:26:5: warning: single-argument constructors must be marked explicit to avoid unintentional implicit conversions [hicpp-explicit-conversions]
    GetUpdatesTask(const shared_ptr<PollingChat::PollingChatSessionPrx>& session) :
    ^
    explicit 
74466 warnings generated.
Suppressed 74464 warnings (74464 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatRoom.cpp
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatRoom.cpp:86:43: warning: the parameter 'message' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
ChatRoom::send(const string& name, string message)
                                          ^
                                   const &
74484 warnings generated.
Suppressed 74483 warnings (74483 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionManagerI.cpp
Chat/server/ChatSessionManagerI.cpp:37:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Glacier2::CannotCreateSessionException(ex.what());
              ^
Chat/server/ChatSessionManagerI.cpp:61:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Glacier2::CannotCreateSessionException("internal server error");
              ^
75572 warnings generated.
Suppressed 75570 warnings (75570 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/client/Client.cpp
75243 warnings generated.
Suppressed 75243 warnings (75243 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatServer.cpp
75488 warnings generated.
Suppressed 75488 warnings (75488 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
clang-tidy --use-color -p=/Users/clausklein/Workspace/cpp/ice-demos/cpp11 /Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:17:79: warning: pass by value and use std::move [modernize-pass-by-value]
                           bool trace, const shared_ptr<Ice::Logger>& logger, const std::string& name) :
                                                                              ^~~~~~~~~~~~~~~~~~
                                                                              std::string 
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:31:76: warning: the parameter 'eptr' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
            _callback->initAsync(users, nullptr, [self](std::exception_ptr eptr) { self->failed(eptr); });
                                                                           ^
                                                        const             &
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:44:87: warning: the parameter 'eptr' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
            _callback->joinAsync(e->timestamp, e->name, nullptr, [self](exception_ptr eptr) { self->failed(eptr); });
                                                                                      ^
                                                                        const        &
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:57:88: warning: the parameter 'eptr' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
            _callback->leaveAsync(e->timestamp, e->name, nullptr, [self](exception_ptr eptr) { self->failed(eptr); });
                                                                                       ^
                                                                         const        &
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:70:99: warning: the parameter 'eptr' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
            _callback->sendAsync(e->timestamp, e->name, e->message, nullptr, [self](exception_ptr eptr) { self->failed(eptr); });
                                                                                                  ^
                                                                                    const        &
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:78:30: warning: the parameter #1 is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
    void failed(exception_ptr)
                             ^
                const        &
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:103:66: warning: pass by value and use std::move [modernize-pass-by-value]
ChatSessionI::ChatSessionI(const shared_ptr<ChatRoom>& chatRoom, const string& name, bool trace, const shared_ptr<Ice::Logger>& logger) :
                                                                 ^~~~~~~~~~~~~
                                                                 string 
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:122:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:150:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:159:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Chat::InvalidMessageException("You cannot send messages until you join the chat room.");
              ^
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:173:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Chat::InvalidMessageException(ex.what());
              ^
/Users/clausklein/Workspace/cpp/ice-demos/cpp11/Chat/server/ChatSessionI.cpp:189:15: warning: thrown exception type is not nothrow copy constructible [cert-err60-cpp]
        throw Ice::ObjectNotExistException(__FILE__, __LINE__);
              ^
75303 warnings generated.
Suppressed 75291 warnings (75291 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
bash-3.2$ 
``
ClausKlein commented 2 years ago

this is my .clang-tidy config file:

---
# LLVM version 13.0.0
Checks:
'-*,
  bugprone-*,
  cert-*,
  -cert-err58-cpp,
  clang-diagnostic-*,
  clang-analyzer-*,
  hicpp-*,
  hicpp-avoid-*,
  -hicpp-no-array-decay,
  hicpp-signed-bitwise,
  hicpp-special-member-functions,
  hicpp-use-*,
  hicpp-vararg,
  misc-*,
  -misc-no-recursion,
  -misc-non-private-member-variables-in-classes,
  -misc-unused-parameters,
  modernize-*,
  -modernize-return-braced-init-list,
  -modernize-use-trailing-return-type,
  performance-*,
  portability-*,
  -readability-*,
  -readability-else-after-return,
  -readability-identifier-naming,
  -readability-inconsistent-declaration-parameter-name,
  -readability-implicit-bool-conversion,
  -readability-magic-numbers,
  -readability-redundant-member-init,
  -readability-uppercase-literal-suffix,

  -hicpp-avoid-c-arrays,-modernize-avoid-c-arrays,
  -hicpp-named-parameter,-readability-named-parameter,
  -hicpp-braces-around-statements,-readability-braces-around-statements,
  -hicpp-use-override,-modernize-use-override,
  -hicpp-use-equals-default,-modernize-use-equals-default,
'
WarningsAsErrors:  ''
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle:     file
UseColor:        false
User:            klein_cl
CheckOptions:
  - { key: modernize-loop-convert.MaxCopySize,         value: '16'       }
  - { key: modernize-loop-convert.MinConfidence,       value: reasonable }
  - { key: modernize-loop-convert.NamingStyle,         value: CamelCase  }
  - { key: modernize-pass-by-value.IncludeStyle,       value: llvm       }
  - { key: modernize-replace-auto-ptr.IncludeStyle,    value: llvm       }
  - { key: modernize-use-nullptr.NullMacros,           value: 'NULL'     }
  - { key: readability-identifier-naming.NamespaceCase,          value: lower_case }
  - { key: readability-identifier-naming.ClassCase,              value: CamelCase  }
  - { key: readability-identifier-naming.MemberCase,             value: CamelCase  }
  - { key: readability-identifier-naming.MemberPrefix,           value: m          }
  - { key: readability-identifier-naming.PrivateMemberSuffix,    value: _          }
  - { key: readability-identifier-naming.StructCase,             value: camel_Snake_Back }
  - { key: readability-identifier-naming.FunctionCase,           value: lower_case }
  - { key: readability-identifier-naming.VariableCase,           value: camelBack  }
  - { key: readability-identifier-naming.GlobalConstantCase,     value: UPPER_CASE }
  - { key: readability-identifier-naming.EnumCase,               value: CamelCase  }
  - { key: readability-identifier-naming.EnumPrefix,             value: 'E'        }
  - { key: readability-identifier-naming.GlobalFunctionCase,     value: lower_case }
  - { key: readability-identifier-naming.GlobalVariableCase,     value: CamelCase  }
  - { key: readability-identifier-naming.GlobalVariablePrefix,   value: 'g'        }
  - { key: readability-identifier-naming.ConstexprFunctionCase,  value: CamelCase  }
  - { key: readability-identifier-naming.ConstexprMethodCase,    value: CamelCase  }
  - { key: readability-identifier-naming.ConstexprVariableCase,  value: camelBack  }
...
externl commented 1 year ago

Hi @ClausKlein,

Sorry for the delay in responding to this issue.

Some of the lints are directly relevant to code in this repo, which we'll look into fixing. Most are related to https://github.com/zeroc-ice/ice. It would be best to open a separate issue there and we can look into fixing these in the next major release.