Fix all ruff formatting and linting errors to achieve consistent code style.
Current Issues:
- Nested if statements
- Long lines
- Code complexity
- Formatting inconsistencies
Fixes Required:
- Combine nested if statements using 'and' operator
- Break long lines properly
- Add noqa comments where justified
Benefits:
- Consistent code style
- Better readability
- Automated formatting