Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Update NFA and DFA headers to align with the latest coding guidelines. #58

Merged
merged 392 commits into from
Jan 7, 2025

Conversation

SharafMohamed
Copy link
Contributor

@SharafMohamed SharafMohamed commented Dec 5, 2024

  • Remove redundant type names.
  • Use snake case for variable template parameters.
  • Use backticks (`) to quote member variables in the doc string.

References

  • Depends on PR#57.
  • To review in parallel with PR#57, diff against PR#57 locally. In the repo run:
git fetch upstream pull/57/head:pr-57
git fetch upstream pull/58/head:pr-58
git diff pr-57 pr-58

Description

  • Remove redundant typenames.
  • Rename stateType to state_type.

Validation performed

Previously existing tests still succeed.

Summary by CodeRabbit

  • Documentation
    • Improved comments for clarity in various classes and methods.
  • Chores
    • Removed unnecessary include directives to simplify dependencies.
    • Added a TODO comment for future refactoring of the RegexNFA class.
  • Style
    • Updated method signatures for consistency in the RegexDFAState and RegexDFAStatePair classes.
    • Streamlined access to static members in the NonTerminal class methods.

SharafMohamed and others added 30 commits October 28, 2024 09:38
…egativeTaggedTransition classes into their own files.
…just an id. This object is created and owned by the capture AST, and other AST and NFA states point to these tags.
…Should fix this so the ordering is determinstic.
…ename tag members to make it clear they are positions.
@SharafMohamed SharafMohamed changed the title refactor: Update typenames to remove redundancy and follow naming standards. refactor: Remove redundant typenames and fix typename naming to follow standards. Dec 8, 2024
@SharafMohamed SharafMohamed changed the title refactor: Remove redundant typenames and fix typename naming to follow standards. refactor: Remove redundant typenames and use standard naming for typenames. Dec 8, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
src/log_surgeon/finite_automata/RegexDFAState.hpp (1)

62-64: Consider following the coding guideline for boolean expressions.

The condition RegexDFAStateType::Byte == state_type already follows the guideline of putting the constant on the left side of the comparison. However, for consistency, consider applying the same pattern throughout the method.

Apply this diff:

     if constexpr (RegexDFAStateType::Byte == state_type) {
         return m_bytes_transition[character];
     } else {
         if (character < cSizeOfByte) {
             return m_bytes_transition[character];
         }
         std::unique_ptr<std::vector<typename Tree::Data>> result
                 = m_tree_transitions.find(Interval(character, character));
         assert(result->size() <= 1);
-        if (false == result->empty()) {
+        if (true == result->empty()) {
+            return nullptr;
+        }
-            return result->front().m_value;
-        }
-        return nullptr;
+        return result->front().m_value;
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a4a93b4 and 827d39c.

📒 Files selected for processing (2)
  • src/log_surgeon/finite_automata/RegexDFAState.hpp (2 hunks)
  • src/log_surgeon/finite_automata/RegexDFAStatePair.hpp (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/log_surgeon/finite_automata/RegexDFAStatePair.hpp
🧰 Additional context used
📓 Path-based instructions (1)
src/log_surgeon/finite_automata/RegexDFAState.hpp (1)

Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

📓 Learnings (1)
src/log_surgeon/finite_automata/RegexDFAState.hpp (1)
Learnt from: SharafMohamed
PR: y-scope/log-surgeon#48
File: src/log_surgeon/finite_automata/RegexNFAState.hpp:0-0
Timestamp: 2024-11-13T20:02:13.737Z
Learning: In `src/log_surgeon/finite_automata/RegexNFAState.hpp`, the constructor `RegexNFAState(std::set<Tag const*> tags, RegexNFAState const* dest_state)` has been updated to use `std::vector<Tag const*> tags` instead of `std::set`.
🔇 Additional comments (3)
src/log_surgeon/finite_automata/RegexDFAState.hpp (3)

22-22: LGTM! The template parameter renaming improves consistency.

The change from stateType to state_type follows standard C++ naming conventions, and the simplified type alias improves code readability.

Also applies to: 25-25


55-59: LGTM! Well-documented conditional type declaration.

The member variable declarations are clear and well-documented. The use of std::conditional_t for compile-time type selection is appropriate, and the comment effectively explains the empty tuple case.


43-43: LGTM! Method signatures are clear and consistent.

The simplified parameter types in method signatures improve readability while maintaining type safety.

Also applies to: 51-51

Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is a comment for myself): since this PR has many different types of fixes, I think we need to have a multi-line commit message when we merge.

Copy link
Member

@LinZhihao-723 LinZhihao-723 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For commit message, how about:

refactor: Update NFA and DFA headers to align with the latest coding guidelines:
- Remove redundant type names.
- Use snake case for variable template parameters.
- Use backticks (`) to quote member variables in the doc string.

Notice that we should use multi-line commit message

@SharafMohamed SharafMohamed changed the title refactor: Remove redundant typenames and use standard naming for typenames. refactor: Update NFA and DFA headers to align with the latest coding guidelines: - Remove redundant type names. - Use snake case for variable template parameters. - Use backticks (`) to quote member variables in the doc string. Jan 7, 2025
@SharafMohamed SharafMohamed changed the title refactor: Update NFA and DFA headers to align with the latest coding guidelines: - Remove redundant type names. - Use snake case for variable template parameters. - Use backticks (`) to quote member variables in the doc string. refactor: Update NFA and DFA headers to align with the latest coding guidelines. Jan 7, 2025
@SharafMohamed SharafMohamed merged commit c5017ab into y-scope:main Jan 7, 2025
10 checks passed
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