Skip to content

Exception block static analyzer tool (RavenDB-3879)#1

Merged
ayende merged 6 commits intoravendb:masterfrom
ElemarJR:ExceptionBlock
Jan 10, 2016
Merged

Exception block static analyzer tool (RavenDB-3879)#1
ayende merged 6 commits intoravendb:masterfrom
ElemarJR:ExceptionBlock

Conversation

@ElemarJR
Copy link
Copy Markdown
Contributor

@ElemarJR ElemarJR commented Jan 5, 2016

Hello there,

This PR addresses the following scenarios:

empty catch blocks will generate a diagnostic asking for a properly implementation or comment

            try
            {
                // do something
            }
            catch (Exception ex)
            {
            }

catch blocks with just logging (followed or not with a return or break statement) will generate a diagnostic asking for a comment

try
            {
                // do something
            }
            catch (Exception ex)
            {
                log.Error(""bla bla"", ex);
            }

"try if not null dispose pattern" will not generate any diagnostic

            try
            {
                foo.Dispose();
            }
            catch {}
            try
            {
                if (foo != null) foo.Dispose();
            }
            catch {}

catch blocks with ToDo Comments (TODO, HACK, UNDONE, FIXME) generates a diagnostic reporting this as a problem

            try
            {
                // do something
            }
            catch (Exception ex)
            {
                log.Error(""This was an error"", ex); 
                // TODO: I should write a good comment here
            }

This is it.

ayende added a commit that referenced this pull request Jan 10, 2016
Exception block static analyzer tool (RavenDB-3879)
@ayende ayende merged commit 0f40682 into ravendb:master Jan 10, 2016
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.

2 participants