<table><tr><td style="">dhaumann added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D4537" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>The patch looks already much better. I have added comments below.</p>
<p>Btw, did you copy some code from another project? If so, we need to be careful, since KTextEditor is LGPLv+2.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18253" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">CMakeLists.txt:54</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"># EditorConfig support
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"># TODO: find oldest working version (0.12.0 was released 2014-10-12)
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">find_package(editorconfig "0.12.0")
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I think you can just write "# EditorConfig support (0.12.0 was released 2014-10-12)"<br />
There is no need for looking for even older versions I think.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18254" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">CMakeLists.txt:89</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">document/katebuffer.cpp
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;">document/editorconfig.cpp
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Since the editorconfig is optional, I would make compiling this optional as well:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">if (EDITORCONFIG_FOUND) # optional support for EditorConfig
set(ktexteditor_LIB_SRCS
${ktexteditor_LIB_SRCS}
document/editorconfig.cpp
)
endif()</pre></div>
<p style="padding: 0; margin: 8px;">This way, it's truly optional :-)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18259" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">editorconfig.cpp:23</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span class="n">EditorConfig</span><span style="color: #aa2211">::</span><span class="n">EditorConfig</span><span class="p">(</span><span class="n">KTextEditor</span><span style="color: #aa2211">::</span><span class="n">DocumentPrivate</span> <span style="color: #aa2211">*</span><span class="n">document</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Better is to write:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">EditorConfig::EditorConfig(KTextEditor::DocumentPrivate *document)
: m_document(document)
, m_handle(0)
{
// ...
}</pre></div></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18258" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">editorconfig.cpp:160</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">int</span> <span class="n">code</span> <span style="color: #aa2211">=</span> <span class="n">editorconfig_parse</span><span class="p">(</span><span class="n">m_document</span><span style="color: #aa2211">-></span><span class="n">url</span><span class="p">().</span><span class="n">toLocalFile</span><span class="p">().</span><span class="n">toStdString</span><span class="p">().</span><span class="n">c_str</span><span class="p">(),</span> <span class="n">m_handle</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">const int code = ...</p>
<p style="padding: 0; margin: 8px;">Please use const *whenever possible* :-)</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18261" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">editorconfig.h:56-57</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">static</span> <span style="color: #aa4000">bool</span> <span style="color: #004012">checkIntValue</span><span class="p">(</span><span class="n">QString</span> <span class="n">value</span><span class="p">,</span> <span style="color: #aa4000">int</span> <span style="color: #aa2211">*</span><span class="n">result</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">void</span> <span style="color: #004012">interpret</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #aa4000">void</span> <span style="color: #004012">interpretLine</span><span class="p">(</span><span style="color: #aa4000">const</span> <span style="color: #aa4000">char</span> <span style="color: #aa2211">*</span><span class="n">key</span><span class="p">,</span> <span style="color: #aa4000">const</span> <span style="color: #aa4000">char</span> <span style="color: #aa2211">*</span><span class="n">value</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I would prefer to merge these into parse(), then we also do not need all the member variables anymore.</p>
<p style="padding: 0; margin: 8px;">Rule of thumb: Each member variable adds more states to a class. The more states, the less easy it is to understand when a member changes, since it can be used in any function in the class. In contrast, if variables are local to a function, this reduces states of the class. Therefore, it is typically much easier to understand what the class is doing.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18257" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">katedocument.cpp:2589-2590</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span style="color: #74777d">// file, if such is provided</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">EditorConfig</span> <span style="color: #aa2211">*</span><span class="n">editorConfig</span> <span style="color: #aa2211">=</span> <span style="color: #aa4000">new</span> <span class="n">EditorConfig</span><span class="p">(</span><span style="color: #aa4000">this</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"> <span class="n">editorConfig</span><span style="color: #aa2211">-></span><span class="n">parse</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span style="color: #304a96">#endif</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">No need to put this on the heap, especially since we are also missing a delete here (memory leak). Just write:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">EditorConfig editorConfig(this);
editorConfig.parse();</pre></div></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D4537#inline-18256" rel="noreferrer">View Inline</a><span style="color: #4b4d51; font-weight: bold;">katedocument.h:29-31</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span style="color: #304a96">#ifdef EDITORCONFIG_FOUND</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span style="color: #304a96">#include</span> <span class="cpf">"editorconfig.h"</span><span style="color: #304a96"></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: #d0ffd0;"><span style="color: #304a96">#endif</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">It is enough to move this to the .cpp file, since it is completely unused in the header or by any other files.</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R39 KTextEditor</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D4537" rel="noreferrer">https://phabricator.kde.org/D4537</a></div></div><br /><div><strong>EMAIL PREFERENCES</strong><div><a href="https://phabricator.kde.org/settings/panel/emailpreferences/" rel="noreferrer">https://phabricator.kde.org/settings/panel/emailpreferences/</a></div></div><br /><div><strong>To: </strong>gszymaszek, KTextEditor<br /><strong>Cc: </strong>dhaumann, kwrite-devel, Frameworks<br /></div>