1"use strict";(self.webpackChunkopa_website=self.webpackChunkopa_website||[]).push([[25745],{28453:(e,n,l)=>{l.d(n,{R:()=>i,x:()=>o});var r=l(96540);const t={},s=r.createContext(t);function i(e){const n=r.useContext(s);return r.useMemo((function(){return"function"==typeof e?e(n):{...n,...e}}),[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(t):e.components||t:i(e.components),r.createElement(s.Provider,{value:n},e.children)}},69145:(e,n,l)=>{l.r(n),l.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>r,toc:()=>c});const r=JSON.parse('{"id":"rules/style/file-length","title":"file-length","description":"Summary: Max file length exceeded","source":"@site/projects/regal/rules/style/file-length.md","sourceDirName":"rules/style","slug":"/rules/style/file-length","permalink":"/projects/regal/rules/style/file-length","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{},"sidebar":"autoSidebar","previous":{"title":"external-reference","permalink":"/projects/regal/rules/style/external-reference"},"next":{"title":"function-arg-return","permalink":"/projects/regal/rules/style/function-arg-return"}}');var t=l(74848),s=l(28453);const i={},o="file-length",a={},c=[{value:"Rationale",id:"rationale",level:2},{value:"Configuration Options",id:"configuration-options",level:2},{value:"Related Resources",id:"related-resources",level:2}];function h(e){const n={a:"a",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.header,{children:(0,t.jsx)(n.h1,{id:"file-length",children:"file-length"})}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Summary"}),": Max file length exceeded"]}),"\n",(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.strong,{children:"Category"}),": Style"]}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Avoid"})}),"\n",(0,t.jsx)(n.p,{children:"Excessively large policy files."}),"\n",(0,t.jsx)(n.p,{children:(0,t.jsx)(n.strong,{children:"Prefer"})}),"\n",(0,t.jsx)(n.p,{children:"Splitting large policy files into smaller ones."}),"\n",(0,t.jsx)(n.h2,{id:"rationale",children:"Rationale"}),"\n",(0,t.jsx)(n.p,{children:"Putting too much logic into a single file makes your policy harder to browse, read and maintain. Splitting logic into\nseveral smaller files, and composing policy by proper use of packages and imports, highlights dependencies and\nmakes it easier to reason about."}),"\n",(0,t.jsxs)(n.p,{children:["Note that even a single ",(0,t.jsx)(n.strong,{children:"package"}),' may be split up across several files! This is sometimes useful when different\nfeatures or functions belong in the same "group", but are not directly related to each other. An example of this could\nbe having a single package for configuration split across different files for different parts or functions of that\nconfiguration.']}),"\n",(0,t.jsx)(n.p,{children:"As an added bonus, some tools \u2014 like Regal! \u2014 may even benefit from avoiding huge files as they process files in\nparallel and thus will be able to handle many smaller files faster than a few large ones."}),"\n",(0,t.jsx)(n.h2,{id:"configuration-options",children:"Configuration Options"}),"\n",(0,t.jsxs)(n.p,{children:["This linter rule provides the following ",(0,t.jsx)(n.a,{href:"https://www.openpolicyagent.org/projects/regal/configuration",children:"configuration options"}),":"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-yaml",metastring:'title=".regal/config.yaml or .regal.yaml"',children:'rules:\n style:\n file-length:\n # one of "error", "warning", "ignore"\n level: error\n # default limit is 500 lines\n max-file-length: 500\n'})}),"\n",(0,t.jsx)(n.h2,{id:"related-resources",children:"Related Resources"}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:["Styra Blog: ",(0,t.jsx)(n.a,{href:"https://web.archive.org/web/https://www.styra.com/blog/dynamic-policy-composition-for-opa/",children:"Dynamic Policy Composition"})]}),"\n",(0,t.jsxs)(n.li,{children:["Regal Docs: ",(0,t.jsx)(n.a,{href:"https://www.openpolicyagent.org/projects/regal/rules/style/line-length",children:"line-length"})]}),"\n",(0,t.jsxs)(n.li,{children:["Regal Docs: ",(0,t.jsx)(n.a,{href:"https://www.openpolicyagent.org/projects/regal/rules/style/rule-length",children:"rule-length"})]}),"\n",(0,t.jsxs)(n.li,{children:["GitHub: ",(0,t.jsx)(n.a,{href:"https://github.com/open-policy-agent/regal/blob/main/bundle/regal/rules/style/file-length/file_length.rego",children:"Source Code"})]}),"\n"]})]})}function d(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,t.jsx)(n,{...e,children:(0,t.jsx)(h,{...e})}):h(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.