Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .credo.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# This file contains the configuration for Credo
#
# If you find that you need to change the default configuration,
# it's easiest to just edit this file directly.
#
# More information on Credo can be found here:
# https://github.com/rrrene/credo
%{
configs: [
%{
name: "default",
files: %{
included: ["lib/", "test/"],
excluded: [~r"/_build/", ~r"/deps/", ~r"/node_modules/"]
},
plugins: [],
requires: [],
strict: false,
parse_timeout: 5000,
color: true,
checks: %{
enabled: [
## Consistency Checks
{Credo.Check.Consistency.ExceptionNames, []},
{Credo.Check.Consistency.LineEndings, []},
{Credo.Check.Consistency.ParameterPatternMatching, []},
{Credo.Check.Consistency.SpaceAroundOperators, []},
{Credo.Check.Consistency.SpaceInParentheses, []},
{Credo.Check.Consistency.TabsOrSpaces, []},

## Design Checks
{Credo.Check.Design.AliasUsage, [priority: :low, if_nested_deeper_than: 2, if_called_more_often_than: 0]},
{Credo.Check.Design.TagFIXME, []},
{Credo.Check.Design.TagTODO, [exit_status: 0]},

## Readability Checks
{Credo.Check.Readability.AliasOrder, []},
{Credo.Check.Readability.FunctionNames, []},
{Credo.Check.Readability.LargeNumbers, []},
{Credo.Check.Readability.MaxLineLength, [priority: :low, max_length: 120]},
{Credo.Check.Readability.ModuleAttributeNames, []},
{Credo.Check.Readability.ModuleDoc, []},
{Credo.Check.Readability.ModuleNames, []},
{Credo.Check.Readability.ParenthesesInCondition, []},
{Credo.Check.Readability.ParenthesesOnZeroArityDefs, []},
{Credo.Check.Readability.PipeIntoAnonymousFunctions, []},
{Credo.Check.Readability.PredicateFunctionNames, []},
{Credo.Check.Readability.PreferImplicitTry, []},
{Credo.Check.Readability.RedundantBlankLines, []},
{Credo.Check.Readability.Semicolons, []},
{Credo.Check.Readability.SpaceAfterCommas, []},
{Credo.Check.Readability.StringSigils, []},
{Credo.Check.Readability.TrailingBlankLine, []},
{Credo.Check.Readability.TrailingWhiteSpace, []},
{Credo.Check.Readability.UnnecessaryAliasExpansion, []},
{Credo.Check.Readability.VariableNames, []},
{Credo.Check.Readability.WithSingleClause, []},

## Refactoring Opportunities
{Credo.Check.Refactor.Apply, []},
{Credo.Check.Refactor.CondStatements, []},
{Credo.Check.Refactor.CyclomaticComplexity, []},
{Credo.Check.Refactor.FunctionArity, []},
{Credo.Check.Refactor.LongQuoteBlocks, []},
{Credo.Check.Refactor.MatchInCondition, []},
{Credo.Check.Refactor.MapJoin, []},
{Credo.Check.Refactor.NegatedConditionsInUnless, []},
{Credo.Check.Refactor.NegatedConditionsWithElse, []},
{Credo.Check.Refactor.Nesting, []},
{Credo.Check.Refactor.UnlessWithElse, []},
{Credo.Check.Refactor.WithClauses, []},
{Credo.Check.Refactor.FilterFilter, []},
{Credo.Check.Refactor.RejectReject, []},
{Credo.Check.Refactor.RedundantWithClauseResult, []},

## Warnings
{Credo.Check.Warning.ApplicationConfigInModuleAttribute, []},
{Credo.Check.Warning.BoolOperationOnSameValues, []},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck, []},
{Credo.Check.Warning.IExPry, []},
{Credo.Check.Warning.IoInspect, []},
{Credo.Check.Warning.OperationOnSameValues, []},
{Credo.Check.Warning.OperationWithConstantResult, []},
{Credo.Check.Warning.RaiseInsideRescue, []},
{Credo.Check.Warning.SpecWithStruct, []},
{Credo.Check.Warning.WrongTestFileExtension, []},
{Credo.Check.Warning.UnusedEnumOperation, []},
{Credo.Check.Warning.UnusedFileOperation, []},
{Credo.Check.Warning.UnusedKeywordOperation, []},
{Credo.Check.Warning.UnusedListOperation, []},
{Credo.Check.Warning.UnusedPathOperation, []},
{Credo.Check.Warning.UnusedRegexOperation, []},
{Credo.Check.Warning.UnusedStringOperation, []},
{Credo.Check.Warning.UnusedTupleOperation, []},
{Credo.Check.Warning.UnsafeExec, []}
],
disabled: [
# Controversial and experimental checks (opt-in, just move the check to `:enabled`)
{Credo.Check.Consistency.MultiAliasImportRequireUse, []},
{Credo.Check.Consistency.UnusedVariableNames, []},
{Credo.Check.Design.DuplicatedCode, []},
{Credo.Check.Design.SkipTestWithoutComment, []},
{Credo.Check.Readability.AliasAs, []},
{Credo.Check.Readability.BlockPipe, []},
{Credo.Check.Readability.ImplTrue, []},
{Credo.Check.Readability.MultiAlias, []},
{Credo.Check.Readability.NestedFunctionCalls, []},
{Credo.Check.Readability.SeparateAliasRequire, []},
{Credo.Check.Readability.SingleFunctionToBlockPipe, []},
{Credo.Check.Readability.SinglePipe, []},
{Credo.Check.Readability.Specs, []},
{Credo.Check.Readability.StrictModuleLayout, []},
{Credo.Check.Readability.WithCustomTaggedTuple, []},
{Credo.Check.Refactor.ABCSize, []},
{Credo.Check.Refactor.AppendSingleItem, []},
{Credo.Check.Refactor.DoubleBooleanNegation, []},
{Credo.Check.Refactor.FilterReject, []},
{Credo.Check.Refactor.IoPuts, []},
{Credo.Check.Refactor.MapMap, []},
{Credo.Check.Refactor.ModuleDependencies, []},
{Credo.Check.Refactor.NegatedIsNil, []},
{Credo.Check.Refactor.PipeChainStart, []},
{Credo.Check.Refactor.RejectFilter, []},
{Credo.Check.Refactor.VariableRebinding, []},
{Credo.Check.Warning.LazyLogging, []},
{Credo.Check.Warning.LeakyEnvironment, []},
{Credo.Check.Warning.MapGetUnsafePass, []},
{Credo.Check.Warning.MixEnv, []},
{Credo.Check.Warning.UnsafeToAtom, []}
]
}
}
]
}
44 changes: 44 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Git
.git
.gitignore

# Build artifacts
_build
deps
*.ez
blog_engine

# Documentation
doc
docs

# Test
test
cover
*.coverdata

# Development
.elixir_ls
.vscode
.idea

# OS
.DS_Store
Thumbs.db

# Data files (mount as volume instead)
priv/data/*.json

# CI/CD
.github

# Other
README.md
CHANGELOG.md
CONTRIBUTING.md
CODE_OF_CONDUCT.md
SECURITY.md
Makefile
examples
scripts
backups
33 changes: 33 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is used by various editors and IDEs to maintain
# consistent coding styles across different editors and IDEs.
# See https://editorconfig.org for more information.

root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.{ex,exs}]
indent_style = space
indent_size = 2

[*.{md,markdown}]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[Makefile]
indent_style = tab

[*.json]
indent_size = 2

[*.sh]
indent_style = space
indent_size = 2
5 changes: 5 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
line_length: 120
]
39 changes: 39 additions & 0 deletions .git-hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Commit message hook for BlogEngine
# Validates commit message format
# Install: ln -sf ../../.git-hooks/commit-msg .git/hooks/commit-msg

commit_msg_file=$1
commit_msg=$(cat "$commit_msg_file")

# Skip merge commits
if echo "$commit_msg" | grep -q "^Merge"; then
exit 0
fi

# Check minimum length
if [ ${#commit_msg} -lt 10 ]; then
echo "❌ Commit message too short (minimum 10 characters)"
echo " Current: ${#commit_msg} characters"
exit 1
fi

# Check for imperative mood (starts with verb)
first_word=$(echo "$commit_msg" | head -n1 | awk '{print $1}')
if echo "$first_word" | grep -qE '^(Add|Fix|Update|Remove|Refactor|Document|Test|Improve|Create|Delete|Move|Rename|Extract|Optimize|Merge|Bump|Revert)'; then
exit 0
fi

# Warning for non-standard format
echo "⚠️ Warning: Commit message should start with an imperative verb"
echo " Examples: Add, Fix, Update, Remove, Refactor, etc."
echo " Current: $first_word"
echo ""
echo "Continue anyway? (y/N)"
read -r response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
exit 0
else
exit 1
fi
51 changes: 51 additions & 0 deletions .git-hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash

# Pre-commit hook for BlogEngine
# Runs code quality checks before allowing commit
# Install: ln -sf ../../.git-hooks/pre-commit .git/hooks/pre-commit

set -e

echo "Running pre-commit checks..."
echo ""

# Check if mix is available
if ! command -v mix &> /dev/null; then
echo "⚠️ Mix not found. Skipping Elixir checks."
exit 0
fi

# Run formatter check
echo "🔍 Checking code formatting..."
if ! mix format --check-formatted 2>&1 | grep -q "mix format"; then
echo "✓ Code is properly formatted"
else
echo "❌ Code formatting issues found"
echo " Run: mix format"
exit 1
fi

# Run Credo
echo ""
echo "🔍 Running Credo..."
if mix credo --strict 2>&1 | grep -q "Warnings"; then
echo "⚠️ Credo warnings found"
echo " Run: mix credo --strict"
# Don't fail on warnings, just notify
else
echo "✓ Credo checks passed"
fi

# Run tests
echo ""
echo "🧪 Running tests..."
if mix test --trace; then
echo "✓ All tests passed"
else
echo "❌ Tests failed"
exit 1
fi

echo ""
echo "✅ Pre-commit checks passed!"
echo ""
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Funding options for BlogEngine
# Uncomment and update with your funding platforms

# github: [codeforgood-org]
# patreon: username
# open_collective: blogengine
# ko_fi: username
# tidelift: npm/package-name
# community_bridge: project-name
# liberapay: username
# issuehunt: username
# custom: ['https://example.com']
47 changes: 47 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Bug Report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---

## Bug Description

A clear and concise description of what the bug is.

## Steps To Reproduce

1. Go to '...'
2. Run command '...'
3. Enter input '...'
4. See error

## Expected Behavior

A clear and concise description of what you expected to happen.

## Actual Behavior

A clear and concise description of what actually happened.

## Error Messages

```
Paste any error messages here
```

## Environment

- **OS:** [e.g. macOS 13.0, Ubuntu 22.04, Windows 11]
- **Elixir version:** [run `elixir --version`]
- **Erlang/OTP version:** [shown in `elixir --version` output]
- **BlogEngine version/commit:** [e.g. v1.0.0 or commit hash]

## Additional Context

Add any other context about the problem here. Screenshots, logs, or data files can be helpful.

## Possible Solution

If you have ideas about what might be causing this or how to fix it, please share!
Loading
Loading